{"record":{"id":"22eff46ca369a4b8","repo":"alibaba/spring-ai-alibaba","slug":"updateapperror","errorCode":"UpdateAppError","errorMessage":"Failed to update app.","messagePattern":"Failed to update 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":226,"sourceCode":"\t\t\tif (StringUtils.isNotBlank(application.getName())) {\n\t\t\t\tentity.setName(application.getName());\n\t\t\t}\n\t\t\tif (StringUtils.isNotBlank(application.getDescription())) {\n\t\t\t\tentity.setDescription(application.getDescription());\n\t\t\t}\n\n\t\t\tentity.setGmtModified(new Date());\n\t\t\tentity.setModifier(context.getAccountId());\n\t\t\tthis.updateById(entity);\n\n\t\t\tString key = getApplicationCacheKey(entity.getWorkspaceId(), entity.getAppId());\n\t\t\tredisManager.put(key, entity);\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.UPDATE_AGENT_ERROR.toError(), e);\n\t\t}\n\t}\n\n\t/**\n\t * Deletes an application and its versions\n\t * @param appId ID of the application to delete\n\t */\n\t@Override\n\tpublic void deleteApp(String appId) {\n\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\t\t// delete from db\n\t\tAppEntity entity = getAppById(context.getWorkspaceId(), appId);\n\t\tif (entity == null) {\n\t\t\treturn;\n\t\t}\n\n\t\t// delete all versions first\n\t\tLambdaUpdateWrapper<AppVersionEntity> updateWrapper = new LambdaUpdateWrapper<>();","sourceCodeStart":208,"sourceCodeEnd":244,"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#L208-L244","documentation":"BizException with code UpdateAgentError thrown by AppServiceImpl.updateApp's catch-all for any non-BizException failure while persisting an app update, including the Redis cache write (redisManager.put). The original exception is attached as the cause.","triggerScenarios":"Database update fails (connection, constraint violation, optimistic-lock conflict); Redis cache unavailable or serialization error during redisManager.put; unexpected exceptions in the update path.","commonSituations":"Redis down or misconfigured in the environment; DB schema drift after version upgrade; field values violating column limits on update.","solutions":["Inspect BizException.getCause() to identify whether the failure came from the DB update or the Redis cache write.","Check Redis connectivity/configuration (redisManager) and DB health.","Retry after infra recovery; ensure the DB row and cache are not left inconsistent (re-read the app to verify)."],"exampleFix":"// before\ncatch (BizException e) { throw e; }\n// after\ntry {\n    appService.updateApp(application);\n} catch (BizException e) {\n    log.error(\"updateApp failed: {}\", e.getMessage(), e.getCause());\n    throw e;\n}","handlingStrategy":"retry","validationCode":"// pre-check dependencies\nAssert.notNull(application.getAppId(), \"appId required\");\n// verify infra: redis ping and DB select must succeed before update","typeGuard":null,"tryCatchPattern":"try { appService.updateApp(application); } catch (BizException e) { log.error(\"update failed, cause={}\", e.getCause()); if (isTransient(e.getCause())) { retryOnce(application); } else throw e; }","preventionTips":["Monitor Redis availability where AppServiceImpl caches entities.","Log and alert on BizException.getCause() to catch infra regressions early.","Re-read the app after failures to detect DB/cache inconsistency."],"tags":["database","redis","cache-write"],"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"}