{"record":{"id":"6c9d6ca748301e20","repo":"alibaba/spring-ai-alibaba","slug":"appnotfound","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/AgentServiceImpl.java","lineNumber":161,"sourceCode":"\t\t\t}\n\n\t\t\tString appId = request.getAppId();\n\t\t\tif (StringUtils.isBlank(appId)) {\n\t\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"appId\"));\n\t\t\t}\n\n\t\t\tif (CollectionUtils.isEmpty(request.getMessages())) {\n\t\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"messages\"));\n\t\t\t}\n\n\t\t\tif (Objects.isNull(context.getWorkspaceId())) {\n\t\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"workspace_id\"));\n\t\t\t}\n\n\t\t\t// get app config\n\t\t\tApplication app = appService.getApp(appId);\n\t\t\tif (app == null) {\n\t\t\t\tthrow new BizException(ErrorCode.APP_NOT_FOUND.toError());\n\t\t\t}\n\n\t\t\tString configStr;\n\t\t\tif (request.isDraft()) {\n\t\t\t\tconfigStr = app.getConfigStr();\n\t\t\t\tif (configStr == null) {\n\t\t\t\t\tthrow new BizException(ErrorCode.APP_CONFIG_NOT_FOUND.toError());\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconfigStr = app.getPubConfigStr();\n\t\t\t\tif (configStr == null) {\n\t\t\t\t\tthrow new BizException(ErrorCode.APP_NOT_PUBLISHED.toError());\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontext.setAppType(app.getType());\n\t\t\tcontext.setConfig(JsonUtils.fromJson(configStr, AgentConfig.class));","sourceCodeStart":143,"sourceCodeEnd":179,"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/AgentServiceImpl.java#L143-L179","documentation":"BizException (APP_NOT_FOUND) thrown by AgentServiceImpl.checkAndInitContext when appService.getApp(appId) returns null. The appId passed validation but no Application record exists in the resolved scope.","triggerScenarios":"call/streamCall with a syntactically valid appId that does not match any stored application.","commonSituations":"App deleted in the console; typo in appId; app belongs to a different workspace/account; environment mismatch (prod app id used against a dev database).","solutions":["Verify the appId in the platform console or via the app list API and correct it.","Confirm the workspace/account context matches the workspace the app belongs to.","Recreate or re-import the app if it was deleted."],"exampleFix":"// before\nrequest.setAppId(\"app-9x8y7z\"); // deleted app\n// after\nrequest.setAppId(\"app-1a2b3c\"); // verified existing app ID","handlingStrategy":"validation","validationCode":"Application app = appService.getApp(appId);\nif (app == null) {\n    throw new IllegalArgumentException(\"App not found: \" + appId);\n}","typeGuard":"boolean appExists(String appId, AppService svc) {\n    return appId != null && svc.getApp(appId) != null;\n}","tryCatchPattern":"try {\n    agentService.call(request, context);\n} catch (BizException e) {\n    if (e.getMessage().contains(\"App can not be found\")) {\n        // refresh app id from catalog, surface 404 to caller\n    }\n}","preventionTips":["Resolve appIds from the app list API, never freeform text.","Keep per-environment app id config files to avoid cross-env mistakes.","Handle app deletion events by invalidating cached ids."],"tags":["not-found","app","configuration"],"backgroundTag":"resource-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"}