{"record":{"id":"76efebb4325f1200","repo":"alibaba/spring-ai-alibaba","slug":"app-component-publish-error","errorCode":"APP_COMPONENT_PUBLISH_ERROR","errorMessage":"Failed to release application as component.","messagePattern":"Failed to release application as 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":181,"sourceCode":"\t\t}\n\t\tif (StringUtils.isBlank(request.getConfig())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"config\"));\n\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\n\t\t// create component\n\t\tAppComponent component = initComponent(request);\n\t\tResult<String> appComponent = appComponentService.createAppComponent(component);\n\t\tif (appComponent.isSuccess()) {\n\t\t\treturn Result.success(context.getRequestId(), appComponent.getData());\n\t\t}\n\t\telse {\n\t\t\tthrow new BizException(ErrorCode.APP_COMPONENT_PUBLISH_ERROR.toError());\n\t\t}\n\t}\n\n\t/**\n\t * Updates an existing application component. Modifies the configuration and details\n\t * of a published component.\n\t * @param code Unique code of the component to update\n\t * @param request Updated component details including: - type: Component type - name:\n\t * Component name - config: Updated configuration - appId: Associated application ID -\n\t * description: Updated description\n\t * @return Result indicating successful update\n\t */\n\t@PutMapping(\"/{code}\")\n\tpublic Result<String> updateComponent(@PathVariable(\"code\") String code, @RequestBody AppComponentQuery request) {\n\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\t\trequest.setCode(code);\n\t\tif (Objects.isNull(request.getType())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"type\"));","sourceCodeStart":163,"sourceCodeEnd":199,"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#L163-L199","documentation":"After passing validation, publishComponent calls appComponentService.createAppComponent(component). If the returned Result is not success (service-level failure such as persistence error or business rule rejection), the controller throws APP_COMPONENT_PUBLISH_ERROR. The cause is hidden from the client; inspect the server logs and the Result message from the service.","triggerScenarios":"POST /appComponent with a fully valid body where appComponentService.createAppComponent returns a failed Result — e.g. duplicate component code, DB insert failure, or internal service error.","commonSituations":"Component with the same code already exists; database constraint violation; service internal error after upgrade/migration.","solutions":["Check server logs for the failure recorded by createAppComponent and its Result message.","Retry after fixing the data issue (e.g. rename if the component code/name collides with an existing published component).","Verify database health and that component tables are migrated.","Check for duplicate component codes via the component list endpoint before republishing."],"exampleFix":"// before\nelse {\n    throw new BizException(ErrorCode.APP_COMPONENT_PUBLISH_ERROR.toError());\n}\n// after\nelse {\n    log.error(\"Publish component failed: {}\", appComponent.getMessage());\n    throw new BizException(ErrorCode.APP_COMPONENT_PUBLISH_ERROR.toError());\n}","handlingStrategy":"try-catch","validationCode":"const existing = await api.getComponentList({ keyword: payload.name });\nif (existing.data.some(c => c.name === payload.name)) throw new Error('a component with this name may already be published');","typeGuard":null,"tryCatchPattern":"try {\n  await api.publishComponent(payload);\n} catch (e) {\n  if (e.code === 'APP_COMPONENT_PUBLISH_ERROR') {\n    // inspect server logs / retry after resolving the service-level cause\n  } else throw e;\n}","preventionTips":["Check for existing components with the same name/code before publishing.","Monitor database health of the admin service.","Remember the client error masks the root cause — always correlate with server logs."],"tags":["database","server-error","publish"],"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-17T15:17:12.973Z"}