{"record":{"id":"d9dbde63e8285d62","repo":"alibaba/spring-ai-alibaba","slug":"appnotfound-d9dbde","errorCode":"AppNotFound","errorMessage":"App can not be found.","messagePattern":"App 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":159,"sourceCode":"\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new BizException(ErrorCode.CREATE_APP_ERROR.toError(), e);\n\t\t}\n\t}\n\n\t/**\n\t * Updates an existing application. Creates new version if application is published\n\t * @param application Updated application details\n\t */\n\t@Override\n\t@Transactional(rollbackFor = Exception.class)\n\tpublic void updateApp(Application application) {\n\t\ttry {\n\t\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\n\t\t\tAppEntity entity = getAppById(context.getWorkspaceId(), application.getAppId());\n\t\t\tif (entity == null) {\n\t\t\t\tthrow new BizException(ErrorCode.APP_NOT_FOUND.toError());\n\t\t\t}\n\n\t\t\t// check if app name exists\n\t\t\tAppEntity appEntity = getAppByName(context.getWorkspaceId(), application.getName());\n\t\t\tif (appEntity != null && !appEntity.getId().equals(entity.getId())) {\n\t\t\t\tthrow new BizException(ErrorCode.APP_NAME_EXISTS.toError());\n\t\t\t}\n\n\t\t\t// update app\n\t\t\tAppStatus status = entity.getStatus();\n\n\t\t\t// add new version only if app status is published\n\t\t\tif (entity.getStatus() == AppStatus.PUBLISHED) {\n\t\t\t\tstatus = AppStatus.PUBLISHED_EDITING;\n\t\t\t\t// copy and create new version\n\t\t\t\tAppVersionEntity versionEntity = entity.getPublishedVersion();\n\t\t\t\tAppVersionEntity newVersion = BeanCopierUtils.copy(versionEntity, AppVersionEntity.class);\n\t\t\t\tnewVersion.setId(null);","sourceCodeStart":141,"sourceCodeEnd":177,"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#L141-L177","documentation":"BizException with code AppNotFound thrown by AppServiceImpl.updateApp when getAppById(workspaceId, application.getAppId()) returns null, meaning the app id does not exist in the caller's workspace. Updates are workspace-scoped, so an id from another workspace also yields this error.","triggerScenarios":"Calling updateApp with an appId that was deleted, mistyped, or created in a different workspace; stale references cached client-side.","commonSituations":"Deploy pipelines referencing apps removed from the workspace; copying app ids across environments; race with a concurrent delete.","solutions":["Verify the appId exists in the current workspace (list apps) before updating.","Confirm RequestContext workspaceId matches the workspace that owns the app.","Catch AppNotFound and recreate the app or abort the update workflow with a clear message."],"exampleFix":"// before\nappService.updateApp(application);\n// after\nApplication existing = appService.getApp(application.getAppId());\nif (existing != null) {\n    appService.updateApp(application);\n}","handlingStrategy":"validation","validationCode":"Application app = appService.getApp(application.getAppId());\nif (app == null) { throw new IllegalStateException(\"app \" + application.getAppId() + \" not in workspace\"); }","typeGuard":null,"tryCatchPattern":"try { appService.updateApp(application); } catch (BizException e) { if (\"AppNotFound\".equals(e.getCode())) { /* recreate or abort */ } else throw e; }","preventionTips":["Resolve appIds from list calls, never from stale caches.","Confirm workspaceId in RequestContext before cross-workspace operations.","Re-fetch the app right before update to avoid delete/update races."],"tags":["not-found","app-management","workspace-scope"],"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"}