{"record":{"id":"5f1729504b014bde","repo":"iflytek/astron-agent","slug":"workflow-chat-http-response-code","errorCode":null,"errorMessage":"Workflow chat HTTP \" + response.code()","messagePattern":"Workflow chat HTTP \" \\+ response\\.code\\(\\)","errorType":"http","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowChatRunClient.java","lineNumber":55,"sourceCode":"    private String chatUrl;\n\n    @Value(\"${workflow.internal-api-key:}\")\n    private String workflowInternalApiKey;\n\n    /** POST the chat request and return the raw response body (final LLMGenerate JSON frame). */\n    public String chat(JSONObject requestBody) throws IOException {\n        Request request = new Request.Builder()\n                .url(chatUrl)\n                .header(\"X-Consumer-Username\", commonConfig.getAppId())\n                .header(\n                        WorkflowInternalApiKey.HEADER,\n                        WorkflowInternalApiKey.requireConfigured(workflowInternalApiKey))\n                .header(\"Authorization\", \"Bearer \" + commonConfig.getApiKey() + \":\" + commonConfig.getApiSecret())\n                .post(RequestBody.create(requestBody.toJSONString(), JSON_MEDIA))\n                .build();\n        try (Response response = CLIENT.newCall(request).execute()) {\n            if (!response.isSuccessful()) {\n                throw new IOException(\"Workflow chat HTTP \" + response.code());\n            }\n            ResponseBody body = response.body();\n            return body == null ? \"\" : body.string();\n        }\n    }\n}\n","sourceCodeStart":37,"sourceCodeEnd":62,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowChatRunClient.java#L37-L62","documentation":"WorkflowChatRunClient.chat performs an OkHttp POST to the workflow chat HTTP endpoint and throws a plain IOException when the HTTP status is not 2xx, embedding the status code in the message. Callers (per tests) translate this into readable error/interrupt messages rather than letting it propagate raw.","triggerScenarios":"The workflow chat endpoint returns 401/403 (bad internal API key or Authorization header), 404 (wrong base URL/path), 429 (rate limit), or 5xx (core workflow service down) so response.isSuccessful() is false.","commonSituations":"Misconfigured commonConfig apiKey/apiSecret; internal API key not configured (WorkflowInternalApiKey.requireConfigured passed earlier but rotated/expired); wrong service URL or the core/workflow service not running; gateway rejecting the Bearer token format.","solutions":["Check response.code() in the message: 401/403 → fix Authorization (Bearer apiKey:apiSecret) and internal API key configuration; 404 → fix endpoint URL; 5xx → check core/workflow service health","Verify commonConfig.getApiKey()/getApiSecret() are set and match the workflow service's expectations","Confirm the core workflow service is reachable from the console backend (network/DNS, docker network)","Catch this IOException in callers and map status codes to user-facing messages as the existing tests do"],"exampleFix":"// before\nthrow new IOException(\"Workflow chat HTTP \" + response.code());\n// after\nString errBody = response.body() != null ? response.body().string() : \"\";\nthrow new IOException(\"Workflow chat HTTP \" + response.code() + \": \" + StringUtils.abbreviate(errBody, 500));","handlingStrategy":"try-catch","validationCode":"// pre-flight: assert config present\nAssert.hasText(commonConfig.getApiKey(), \"apiKey missing\");\nAssert.hasText(commonConfig.getApiSecret(), \"apiSecret missing\");","typeGuard":null,"tryCatchPattern":"try {\n    String body = chat(request);\n} catch (IOException e) {\n    int status = parseStatusCode(e.getMessage()); // \"Workflow chat HTTP <code>\"\n    switch (status) { case 401: case 403: fixAuth(); break; case 404: fixUrl(); break; default: retryOrAlert(); }\n}","preventionTips":["Verify internal API key and apiKey:apiSecret pair are configured and not rotated","Health-check the core workflow service before dispatching chat runs","Map known HTTP statuses to readable messages in callers, as existing tests do"],"tags":["http","okhttp","network"],"backgroundTag":"http-error-response","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"}