{"record":{"id":"ccaecb23529e80a4","repo":"iflytek/astron-agent","slug":"failed-to-query-appid-credentials-please-check-if-appid","errorCode":null,"errorMessage":"Failed to query APPID credentials. Please check if APPID belongs to you or if APPID has been deleted, APPID=","messagePattern":"Failed to query APPID credentials\\. Please check if APPID belongs to you or if APPID has been deleted, APPID=","errorType":"exception","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/extra/AppService.java","lineNumber":109,"sourceCode":"        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\n     * @return AkSk object if this is a special app, null otherwise\n     */\n    private AkSk specialAppHandle(String appId) {\n        if (appId.equals(commonConfig.getAppId())) {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/extra/AppService.java#L91-L127","documentation":"Same error as the APPID credential lookup failure, but the message shows 'APPID=' with no value — the appId argument passed into parseRemoteCredential was null (null concatenation yields the empty string). The remote lookup therefore ran with no identifier and naturally returned no credential.","triggerScenarios":"getAkSk/remoteCallAkSk invoked with a null appId — e.g. the app record or its config was never populated, a lookup returned null and was forwarded directly, or a request field was absent — and parseRemoteCredential built the message via string concatenation of null.","commonSituations":"Missing APPID in application configuration/environment; DB record for the app missing the appId column value; upstream API response mapped to an object whose appId field was never set before the credential call.","solutions":["Trace where getAkSk/remoteCallAkSk obtains appId and find why it is null (missing config property or null entity field).","Guard the entry point: reject null/blank appId before the remote call with a clear client-facing message.","In parseRemoteCredential, build the message with String.valueOf or a blank-check so the log clearly indicates a missing identifier.","Fix the configuration/record so the appId is populated, then retry."],"exampleFix":"// before\nString errMsg = \"Failed to query APPID credentials... APPID=\" + appId;\n// after\nif (appId == null || appId.isBlank()) {\n    throw new BusinessException(ResponseEnum.RESPONSE_FAILED, \"appId is required but was not provided\");\n}\nString errMsg = \"Failed to query APPID credentials... APPID=\" + appId;","handlingStrategy":"validation","validationCode":"// before calling getAkSk/remoteCallAkSk\nif (appId == null || appId.isBlank()) {\n    throw new BusinessException(ResponseEnum.RESPONSE_FAILED, \"appId must be configured before credential lookup\");\n}","typeGuard":"boolean hasAppId(App app) {\n    return app != null && app.getAppId() != null && !app.getAppId().isBlank();\n}","tryCatchPattern":"try {\n    AkSk akSk = appService.getAkSk(appId);\n} catch (BusinessException e) {\n    if (e.getMessage() != null && e.getMessage().endsWith(\"APPID=\")) {\n        // appId was null — fix configuration, not the remote service\n        log.error(\"appId missing in configuration\");\n    }\n}","preventionTips":["Validate appId non-null/non-blank at the entry point of every credential call.","Fail fast on startup if required APPID configuration properties are missing.","Use non-null database defaults or constraints so app records always carry an appId.","Log explicitly 'appId was null' rather than concatenating null into messages."],"tags":["credentials","null-value","appid","missing-config"],"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"}