{"record":{"id":"6dcf37d4bd9bc537","repo":"iflytek/astron-agent","slug":"8001-failed-to-query-appid-credentials-please-check-if-appid","errorCode":"8001","errorMessage":"Failed to query APPID credentials. Please check if APPID belongs to you or if APPID has been deleted, APPID=${appId}","messagePattern":"Failed to query APPID credentials\\. Please check if APPID belongs to you or if APPID has been deleted, APPID=(.+?)","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/extra/AppService.java","lineNumber":105,"sourceCode":"            return akSk;\n        }\n\n        String appUrl = apiUrl.getAppUrl() + \"/key/\" + appId;\n        String resp;\n        try {\n            resp = HeaderAuthHttpTool.tenantGet(\n                    appUrl, apiUrl.getApiKey(), apiUrl.getApiSecret());\n        } catch (NoSuchAlgorithmException | InvalidKeyException | IOException e) {\n            throw new RuntimeException(e);\n        }\n        return parseRemoteCredential(resp, appId, \"uncached\");\n    }\n\n    private AkSk parseRemoteCredential(String response, String appId, String lookupMode) {\n        Object data = CommonTool.checkSystemCallResponse(response);\n        String errMsg = \"Failed to query APPID credentials. Please check if APPID belongs to you or if APPID has been deleted, APPID=\" + appId;\n        if (data == null) {\n            throw new BusinessException(ResponseEnum.RESPONSE_FAILED, errMsg);\n        }\n        JSONArray array = JSON.parseArray(data.toString());\n        if (CollectionUtils.isEmpty(array)) {\n            throw new BusinessException(ResponseEnum.RESPONSE_FAILED, errMsg);\n        }\n        AkSk credential = array.getObject(0, AkSk.class);\n        log.info(\n                \"APP credential query succeeded, appId={}, mode={}, responseChars={}\",\n                appId,\n                lookupMode,\n                response == null ? 0 : response.length());\n        return credential;\n    }\n\n    /**\n     * Handle special application IDs that have predefined credentials\n     *\n     * @param appId The application ID to check","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/extra/AppService.java#L87-L123","documentation":"Thrown by AppService.parseRemoteCredential when the remote credential service returned a response whose data payload is null or an empty array, so no AkSk credential could be extracted. The message embeds the queried appId. It signals the APPID either does not belong to the caller or has been deleted upstream.","triggerScenarios":"getAkSk or remoteCallAkSk calls the remote app-credential API; CommonTool.checkSystemCallResponse returns null data, or JSON.parseArray(data.toString()) yields an empty array for the given appId.","commonSituations":"Typo or stale APPID configured in the caller's environment; the app was deleted in the upstream console; the remote service returns success with an empty list for apps owned by another tenant.","solutions":["Verify the appId passed to getAkSk/remoteCallAkSk exists and belongs to your account in the upstream console.","Check logs to inspect the raw remote response and confirm whether data was null or the array was empty.","Re-create or re-bind the app credentials if the app was deleted, then update the stored appId configuration.","Add pre-validation that rejects empty/blank appId before making the remote call."],"exampleFix":"// before\nAkSk credential = appService.getAkSk(appId);\n// after\nif (appId == null || appId.isBlank()) {\n    throw new IllegalArgumentException(\"appId must be provided before querying AK/SK\");\n}\nAkSk credential = appService.getAkSk(appId);","handlingStrategy":"validation","validationCode":"// before the remote call\nif (appId == null || appId.isBlank()) {\n    throw new BusinessException(ResponseEnum.RESPONSE_FAILED, \"appId is required\");\n}","typeGuard":"boolean hasCredentialPayload(Object data) {\n    if (data == null) return false;\n    JSONArray arr = JSON.parseArray(data.toString());\n    return arr != null && !arr.isEmpty();\n}","tryCatchPattern":"try {\n    AkSk akSk = appService.getAkSk(appId);\n} catch (BusinessException e) {\n    // prompt user to verify the APPID exists and belongs to them\n    log.warn(\"credential lookup failed for appId={}\", appId, e);\n}","preventionTips":["Verify appIds against the upstream console instead of hardcoding them.","Treat deleted apps as a first-class case: check app existence before requesting credentials.","Cache credential lookups with invalidation on app deletion to reduce stale-id calls.","Include the appId in error logs (it already is) to speed triage."],"tags":["credentials","appid","remote-call","aksk"],"backgroundTag":"empty-api-response","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}