{"record":{"id":"9d346b2f52dd7798","repo":"iflytek/astron-agent","slug":"8001-failed-to-get-rsa-public-key","errorCode":"8001","errorMessage":"Failed to get RSA public key: ","messagePattern":"Failed to get RSA public key: ","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/controller/model/ModelController.java","lineNumber":73,"sourceCode":"        String uid = UserInfoManagerHandler.getUserId();\n        dto.setUid(uid);\n        dto.setSpaceId(SpaceInfoUtil.getSpaceId());\n        return modelService.getList(dto, request);\n    }\n\n    @GetMapping(\"/detail\")\n    public ApiResult detail(@RequestParam(name = \"llmSource\") Integer llmSource, @RequestParam(name = \"modelId\") Long modelId, HttpServletRequest request) {\n        return modelService.getDetail(llmSource, modelId, request);\n    }\n\n    @GetMapping(\"/rsa/public-key\")\n    public ApiResult getRsaPublicKey() {\n        try {\n            String publicKey = modelService.getPublicKey();\n            return ApiResult.success(publicKey);\n        } catch (Exception e) {\n            log.error(\"Failed to get RSA public key\", e);\n            throw new BusinessException(ResponseEnum.RESPONSE_FAILED, \"Failed to get RSA public key: \" + e.getMessage());\n        }\n    }\n\n    /**\n     * Check model ownership\n     *\n     * @param llmId\n     * @param serviceId\n     * @param url\n     * @return\n     */\n    @GetMapping(\"/check-model-base\")\n    public ApiResult checkModelBase(@RequestParam(name = \"llmId\") Long llmId,\n            @RequestParam(name = \"uid\") String uid,\n            @RequestParam(name = \"spaceId\", required = false) Long spaceId,\n            @RequestParam(name = \"serviceId\") String serviceId,\n            @RequestParam(name = \"url\") String url) {\n        return ApiResult.success(modelService.checkModelBase(llmId, serviceId, url, uid, spaceId));","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/controller/model/ModelController.java#L55-L91","documentation":"Generic wrapper error (code 8001) thrown by ModelController.getRsaPublicKey when modelService.getPublicKey() throws any Exception. The controller logs the underlying stack trace and rethrows a BusinessException whose message embeds the original exception's message. The real cause is whatever the service failed on (missing key config, keystore/IO problems, etc.).","triggerScenarios":"GET the RSA public key endpoint while the underlying key provider fails: key material not configured, file/classpath resource missing, or the service throws any runtime exception.","commonSituations":"RSA key pair not generated/installed in the deployment environment; wrong key path in configuration; missing config file after an upgrade; startup ordering where the key service is not yet initialized.","solutions":["Read the log line 'Failed to get RSA public key' for the full stack trace to find the root cause.","Verify the RSA key configuration (key path/properties) is present and correct in the service environment.","Generate or install the RSA key pair per deployment docs and restart the service.","Narrow the catch block so specific failures (e.g. missing key resource) surface as distinct error codes instead of the generic RESPONSE_FAILED."],"exampleFix":"// before\nthrow new BusinessException(ResponseEnum.RESPONSE_FAILED, \"Failed to get RSA public key: \" + e.getMessage());\n// after\nlog.error(\"Failed to get RSA public key\", e);\nthrow new BusinessException(ResponseEnum.RESPONSE_FAILED, \"Failed to get RSA public key: \" + e.getClass().getSimpleName() + \": \" + e.getMessage());","handlingStrategy":"try-catch","validationCode":"// client: check endpoint health before relying on the key\nconst res = await fetch('/model/rsa-public-key');\nif (!res.ok) throw new Error('key service unavailable: ' + res.status);","typeGuard":null,"tryCatchPattern":"try {\n  const key = await api.getRsaPublicKey();\n} catch (e) {\n  if (e.code === 8001) {\n    // surface e.message's embedded cause to ops; check RSA key configuration\n    showError('Key service misconfigured: ' + e.message);\n  } else throw e;\n}","preventionTips":["Add RSA key config checks to deployment readiness/health checks.","Alert on the 'Failed to get RSA public key' log pattern.","Keep key generation/installation in the deployment pipeline, not manual steps."],"tags":["rsa","configuration","key-management"],"backgroundTag":"missing-credentials","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}