{"record":{"id":"00feaa8878c11cb4","repo":"alibaba/spring-ai-alibaba","slug":"appversionnotfound","errorCode":"AppVersionNotFound","errorMessage":"App version can not be found.","messagePattern":"App version can not be found\\.","errorType":"error_code","errorClass":"BizException","httpStatus":404,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/AppServiceImpl.java","lineNumber":339,"sourceCode":"\t * @param appId ID of the application to publish\n\t */\n\t@Override\n\tpublic void publishApp(String appId) {\n\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\t\tAppEntity entity = getAppById(context.getWorkspaceId(), appId);\n\t\tif (entity == null) {\n\t\t\tthrow new BizException(ErrorCode.APP_NOT_FOUND.toError());\n\t\t}\n\n\t\tLambdaQueryWrapper<AppVersionEntity> queryWrapper = new LambdaQueryWrapper<>();\n\t\tqueryWrapper.eq(AppVersionEntity::getAppId, appId)\n\t\t\t.eq(AppVersionEntity::getWorkspaceId, context.getWorkspaceId())\n\t\t\t.ne(AppVersionEntity::getStatus, AppStatus.DELETED.getStatus())\n\t\t\t.orderByDesc(AppVersionEntity::getId)\n\t\t\t.last(\"limit 1\");\n\t\tAppVersionEntity versionEntity = appVersionMapper.selectOne(queryWrapper);\n\t\tif (versionEntity == null) {\n\t\t\tthrow new BizException(ErrorCode.APP_VERSION_NOT_FOUND.toError());\n\t\t}\n\n\t\tif (entity.getType() == AppType.BASIC) {\n\t\t\tAgentConfig config = JsonUtils.fromJson(versionEntity.getConfig(), AgentConfig.class);\n\t\t\tif (StringUtils.isBlank(config.getModelProvider())) {\n\t\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"model_provider\"));\n\t\t\t}\n\n\t\t\tif (StringUtils.isBlank(config.getModel())) {\n\t\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"model\"));\n\t\t\t}\n\t\t}\n\n\t\tversionEntity.setStatus(AppStatus.PUBLISHED);\n\t\tversionEntity.setGmtModified(new Date());\n\t\tversionEntity.setModifier(context.getAccountId());\n\t\tappVersionMapper.updateById(versionEntity);\n","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/AppServiceImpl.java#L321-L357","documentation":"BizException with code AppVersionNotFound thrown by AppServiceImpl.publishApp when the app exists but has no version entity to publish (appVersionMapper.selectOne returns null after querying for the latest non-DELETED version). The library refuses to publish an app that has no publishable version/config snapshot.","triggerScenarios":"Publishing a newly created app whose first version was never saved or was marked DELETED; all versions filtered out by the ne(status, DELETED) predicate; draft-only apps with no saved version rows.","commonSituations":"Apps created programmatically without saving a version/config; cleanup jobs soft-deleting all versions; publishing immediately after creation before any edit is saved.","solutions":["Save at least one app version/config (e.g. updateApp) before calling publishApp.","Check the app_version table for rows with the appId that are not status=DELETED.","Publish only after an edit/save workflow has produced a version, not immediately after creation."],"exampleFix":"// before\nappService.createApp(application);\nappService.publishApp(appId); // no version yet\n// after\nString appId = appService.createApp(application);\napplication.setAppId(appId);\nappService.updateApp(application); // persists a version/config\nappService.publishApp(appId);","handlingStrategy":"validation","validationCode":"// ensure a saved version exists before publishing\nappService.updateApp(applicationWithConfig); // persists version data\nappService.publishApp(application.getAppId());","typeGuard":null,"tryCatchPattern":"try { appService.publishApp(appId); } catch (BizException e) { if (\"AppVersionNotFound\".equals(e.getCode())) { /* save a version then retry publish */ } else throw e; }","preventionTips":["Always persist a version/config before publish.","Never soft-delete all versions of an app that must remain publishable.","In automation, publish only after a successful save/edit step."],"tags":["not-found","app-version","publish"],"backgroundTag":"entity-not-found","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}