{"record":{"id":"6ac64754badf7552","repo":"alibaba/spring-ai-alibaba","slug":"app-component-refer-error","errorCode":"APP_COMPONENT_REFER_ERROR","errorMessage":"Failed to query reference of component.","messagePattern":"Failed to query reference of 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":366,"sourceCode":"\t\t\tList<Refer> refers = referService.getReferListByReferCode(code);\n\t\t\tif (!CollectionUtils.isEmpty(refers)) {\n\t\t\t\tfor (Refer refer : refers) {\n\t\t\t\t\tApplication application = appService.getApp(refer.getMainCode());\n\t\t\t\t\tif (application == null || application.getStatus() == AppStatus.DELETED) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tAppComponent appComponent = new AppComponent();\n\t\t\t\t\tappComponent.setAppId(application.getAppId());\n\t\t\t\t\tappComponent.setName(application.getName());\n\t\t\t\t\tAppType type = application.getType();\n\t\t\t\t\tappComponent.setType(type.getValue());\n\t\t\t\t\tappComponentDTOList.add(appComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn Result.success(context.getRequestId(), appComponentDTOList);\n\t\t}\n\t\tcatch (Exception exception) {\n\t\t\tthrow new BizException(ErrorCode.APP_COMPONENT_REFER_ERROR.toError());\n\t\t}\n\n\t}\n\n\t/**\n\t * Queries the configuration of a component by its application ID.\n\t * @param appId Application ID associated with the component\n\t * @return Result containing the component's configuration details\n\t */\n\t@GetMapping(\"/{appId}/query-config\")\n\tpublic Result<AppComponent> queryConfig(@PathVariable(\"appId\") String appId) {\n\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\t\tif (StringUtils.isBlank(appId)) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"appId\"));\n\t\t}\n\t\ttry {\n\t\t\tApplication application = appService.getApp(appId);\n\t\t\tif (application == null) {","sourceCodeStart":348,"sourceCodeEnd":384,"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#L348-L384","documentation":"A catch-all BizException from queryReferInfo: any exception while fetching references via referService.getReferListByReferCode or building the AppComponent DTO list is converted to ErrorCode.APP_COMPONENT_REFER_ERROR. The root cause is not surfaced in the response.","triggerScenarios":"Any RuntimeException inside the try block of GET /appComponent/{code}/query-refer — e.g. refer-table query failure, mapping errors when converting Refer rows to AppComponent DTOs.","commonSituations":"Database connectivity problems; refer records referencing deleted apps/components causing mapping NPEs; schema drift between refer and component tables.","solutions":["Enable debug logging to capture the swallowed exception inside queryReferInfo","Verify database health and the refer table integrity (no dangling references)","Check that all referenced apps/components still exist and map correctly to AppComponent","Retry if the failure was transient"],"exampleFix":"// before\ncatch (Exception exception) {\n    throw new BizException(ErrorCode.APP_COMPONENT_REFER_ERROR.toError());\n}\n// after\ncatch (Exception exception) {\n    log.error(\"Failed to query refer info for code={}\", code, exception);\n    throw new BizException(ErrorCode.APP_COMPONENT_REFER_ERROR.toError());\n}","handlingStrategy":"try-catch","validationCode":"const resp = await fetch(url); if (!resp.ok) throw new Error(`query-refer failed: ${resp.status}`);","typeGuard":"null","tryCatchPattern":"try { ... } catch (e) { if (e.code === 'APP_COMPONENT_REFER_ERROR') { showGenericErrorAndLog(e); } else throw e; }","preventionTips":["Retry transient DB failures with backoff","Keep refer records consistent when deleting apps/components","Add server-side root-cause logging in the catch block"],"tags":["rest","internal-error","error-handling"],"backgroundTag":"api-request-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"}