{"record":{"id":"6914ee237c27e618","repo":"alibaba/spring-ai-alibaba","slug":"app-component-update-error","errorCode":"APP_COMPONENT_UPDATE_ERROR","errorMessage":"Failed to update component.","messagePattern":"Failed to update component\\.","errorType":"error_code","errorClass":"BizException","httpStatus":500,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/controller/AppComponentController.java","lineNumber":224,"sourceCode":"\t\t}\n\t\tif (StringUtils.isBlank(request.getAppId())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"appId\"));\n\t\t}\n\t\tif (StringUtils.isBlank(request.getDescription())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"description\"));\n\t\t}\n\t\tif (StringUtils.isBlank(request.getCode())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"code\"));\n\t\t}\n\n\t\t// update component config\n\t\tAppComponent component = initComponent(request);\n\t\tResult<Integer> integerResult = appComponentService.updateAppComponent(component);\n\t\tif (integerResult.isSuccess()) {\n\t\t\treturn Result.success(context.getRequestId(), \"update success\");\n\t\t}\n\t\telse {\n\t\t\tthrow new BizException(ErrorCode.APP_COMPONENT_UPDATE_ERROR.toError());\n\t\t}\n\n\t}\n\n\t/**\n\t * Deletes an application component. Removes a component from the system by its unique\n\t * code.\n\t * @param code Unique code of the component to delete\n\t * @return Result containing boolean indicating successful deletion\n\t */\n\t@DeleteMapping(\"/{code}\")\n\tpublic Result<Boolean> deleteComponent(@PathVariable(\"code\") String code) {\n\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\t\tif (StringUtils.isBlank(code)) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"code\"));\n\t\t}\n\t\tResult<Void> voidResult = appComponentService.deleteAppComponent(code);\n\t\tif (voidResult.isSuccess()) {","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/controller/AppComponentController.java#L206-L242","documentation":"BizException thrown by AppComponentController.updateComponent when the underlying appComponentService.updateAppComponent call reports a non-success Result. It signals the persistence layer refused the component update (bad state, constraint violation, or internal service failure) rather than a malformed request.","triggerScenarios":"POST/PUT to the component update endpoint with a body that passes initComponent() binding but fails on save — e.g. nonexistent app/component code, conflicting published state, DB constraint, or the service returning an error Result for any internal reason.","commonSituations":"Updating a component whose referenced app was deleted; concurrent edits causing optimistic-lock/state conflicts; database down or migration drift; component code not matching an existing record.","solutions":["Check the server log for the underlying exception logged before this BizException to see the real service/DB error.","Verify the component code and referenced app exist and are in an updatable state.","Confirm the database is reachable and the component table schema matches the current version.","Retry the update with a fresh payload after fixing the data; if transient, re-issue the request."],"exampleFix":"// before: blindly update\nAppComponent component = initComponent(request);\nResult<Integer> r = appComponentService.updateAppComponent(component);\nif (!r.isSuccess()) throw new BizException(ErrorCode.APP_COMPONENT_UPDATE_ERROR.toError());\n// after: pre-validate existence before updating\nAppComponent existing = appComponentService.getAppComponentByCode(component.getCode(), null);\nif (existing == null) throw new BizException(ErrorCode.APP_COMPONENT_NOT_FOUND.toError());\nResult<Integer> r2 = appComponentService.updateAppComponent(component);\nif (!r2.isSuccess()) throw new BizException(ErrorCode.APP_COMPONENT_UPDATE_ERROR.toError());","handlingStrategy":"try-catch","validationCode":"const component = await getComponentByCode(code);\nif (!component) throw new Error(`component ${code} does not exist`);","typeGuard":"boolean isUpdatable(AppComponent c) { return c != null && StringUtils.isNotBlank(c.getCode()) && c.getAppId() != null; }","tryCatchPattern":"try {\n  const res = await api.updateComponent(payload);\n  if (!res.isSuccess) throw new BizError('APP_COMPONENT_UPDATE_ERROR', res);\n} catch (e) {\n  if (e instanceof BizError && e.code === 'APP_COMPONENT_UPDATE_ERROR') {\n    // re-fetch state, surface underlying cause, allow retry after fix\n  }\n}","preventionTips":["Verify the component exists before updating.","Keep component and app data consistent (no dangling app references).","Monitor service logs for the root cause behind update failures.","Handle concurrent edits with optimistic locking."],"tags":["rest-api","persistence","spring","component-update"],"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"}