{"record":{"id":"ad669ac06c054b6d","repo":"iflytek/astron-agent","slug":"system-error-ad669a","errorCode":"SYSTEM_ERROR","errorMessage":"SYSTEM_ERROR","messagePattern":"SYSTEM_ERROR","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/util/BotAIServiceClient.java","lineNumber":175,"sourceCode":"                log.info(\"Image generation request completed, user [{}], response code: {}\", uid, responseCode);\n\n                // Check if there is an error\n                if (responseCode != 0) {\n                    log.error(\"Image generation service returned error, user [{}], error code: {}\", uid, responseCode);\n\n                    // Convert error code to corresponding ResponseEnum and throw\n                    ResponseEnum responseEnum = convertImageErrorCodeToResponseEnum(responseCode);\n                    throw new BusinessException(responseEnum);\n                }\n\n                return result;\n            }\n        } catch (BusinessException e) {\n            // Re-throw BusinessException directly\n            throw e;\n        } catch (Exception e) {\n            log.error(\"Image generation request failed, user [{}]\", uid, e);\n            throw new BusinessException(ResponseEnum.SYSTEM_ERROR);\n        }\n    }\n\n    /**\n     * Text generation request (for opening lines generation and other functions)\n     *\n     * @param question Generation prompt\n     * @param domain Model domain\n     * @param seconds Timeout (seconds)\n     * @return Generated text content\n     * @throws BusinessException Business exception\n     */\n    public String generateText(String question, String domain, int seconds) throws BusinessException, InterruptedException {\n        validateTextGenerationParams(question, domain, seconds);\n        PlatformAccountConfigDto.IflytekOpenPlatformConfig config =\n                platformAccountService.requireIflytekOpenPlatform();\n\n        TextGenerationWebSocketListener listener = null;","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/util/BotAIServiceClient.java#L157-L193","documentation":"generateImage wraps every unexpected failure (network errors, malformed JSON responses, null response bodies, non-401 HTTP failures) into a generic BusinessException with ResponseEnum.SYSTEM_ERROR. BusinessExceptions from the Spark API error mapping are re-thrown unchanged; anything else hits this catch-all. It means the image generation call failed for a reason the client did not specifically classify.","triggerScenarios":"generateImage(uid,prompt,size) throws this when: OkHttp call to the image host fails (DNS/connect/timeout), the response body is empty (IllegalStateException), the JSON response cannot be parsed (JSONObject.parseObject), header.code extraction throws NPE, or any other non-BusinessException RuntimeException occurs inside the try block.","commonSituations":"Spark image API endpoint unreachable from the deployment network (firewall/proxy), malformed or non-JSON response returned by a gateway, intermittent socket timeouts under load, or a bug in response parsing after a platform API change.","solutions":["Check the service log for the 'Image generation request failed, user [...]' stack trace to find the real underlying exception","Verify network connectivity from the console backend to http://spark-openapi.cn-huabei-1.xf-yun.com/v2.1/tti (proxy/firewall/DNS)","Confirm the Spark API response shape still contains header.code; update parsing if the platform changed its response format","Increase httpClient timeouts or add retry logic if failures correlate with load/latency"],"exampleFix":"// before\ncatch (Exception e) {\n    log.error(\"Image generation request failed, user [{}]\", uid, e);\n    throw new BusinessException(ResponseEnum.SYSTEM_ERROR);\n}\n// after\ncatch (IOException e) {\n    log.error(\"Image generation network failure, user [{}]\", uid, e);\n    throw new BusinessException(ResponseEnum.SPARK_API_ENGINE_NETWORK_ERROR);\n}","handlingStrategy":"try-catch","validationCode":"if (uid == null || prompt == null || prompt.isBlank()) { throw new IllegalArgumentException(\"uid and prompt required\"); }","typeGuard":null,"tryCatchPattern":"try { JSONObject r = client.generateImage(uid, prompt, size); } catch (BusinessException e) { log.error(\"Image gen failed: {}\", e.getMessage()); return fallbackImageError(e); }","preventionTips":["Check service logs for the root cause stack trace before guessing","Verify network egress to the Spark image endpoint from the deployment environment","Validate uid/prompt are non-blank before calling","Monitor Spark API response-shape changes after platform upgrades"],"tags":["java","http","image-generation","error-mapping"],"backgroundTag":"api-request-failed","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"}