{"record":{"id":"698db08aaa44ff17","repo":"alibaba/spring-ai-alibaba","slug":"createapperror","errorCode":"CreateAppError","errorMessage":"Failed to create app.","messagePattern":"Failed to create app\\.","errorType":"error_code","errorClass":"BizException","httpStatus":500,"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":143,"sourceCode":"\t\t\tversionEntity.setModifier(context.getAccountId());\n\n\t\t\tString config = JsonUtils.toJson(application.getConfig());\n\t\t\tversionEntity.setConfig(config);\n\t\t\tappVersionMapper.insert(versionEntity);\n\n\t\t\t// update application version\n\t\t\tentity.setLatestVersion(versionEntity);\n\n\t\t\tString key = getApplicationCacheKey(entity.getWorkspaceId(), entity.getAppId());\n\t\t\tredisManager.put(key, entity);\n\n\t\t\treturn appId;\n\t\t}\n\t\tcatch (BizException e) {\n\t\t\tthrow e;\n\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","sourceCodeStart":125,"sourceCodeEnd":161,"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#L125-L161","documentation":"BizException with code CreateAppError thrown by AppServiceImpl.createApp's catch-all for any non-BizException failure during app creation (e.g. DB insert failure via mapper, id generation, cache write). It wraps the original exception as the cause, so the underlying problem is preserved.","triggerScenarios":"Database unavailable or insert fails while persisting the new AppEntity; serialization/conversion failure when copying Application to AppEntity; cache (Redis) errors during creation.","commonSituations":"DB connection pool exhausted or migrations missing; invalid field values violating DB constraints (too-long names); transient infrastructure outages.","solutions":["Inspect the wrapped cause (BizException.getCause()) to find the real failure (DB, cache, mapping).","Verify database connectivity, schema/migrations, and that entity fields satisfy column constraints.","Retry once for transient infra errors only after confirming the app was not partially created."],"exampleFix":"// before\ncatch (Exception e) { log.error(\"create failed\"); }\n// after\ntry {\n    appService.createApp(application);\n} catch (BizException e) {\n    log.error(\"createApp failed: {}\", e.getMessage(), e.getCause());\n}","handlingStrategy":"try-catch","validationCode":"// validate fields before create\nAssert.hasText(application.getName(), \"app name required\");\nAssert.isTrue(application.getName().length() <= 64, \"app name too long for DB column\");","typeGuard":null,"tryCatchPattern":"try { appService.createApp(application); } catch (BizException e) { log.error(\"createApp failed, cause={}”, e.getCause()); /* check infra, then retry or abort */ }","preventionTips":["Keep DB migrations and connection pools healthy before running create flows.","Validate field lengths/types against the AppEntity schema.","Always log BizException.getCause() to surface the wrapped root cause."],"tags":["database","internal-error","app-management"],"backgroundTag":"database-write-failed","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"}