{"record":{"id":"481ccf572cbb8788","repo":"iflytek/astron-agent","slug":"model-domain-cannot-be-empty","errorCode":null,"errorMessage":"Model domain cannot be empty","messagePattern":"Model domain cannot be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/util/BotAIServiceClient.java","lineNumber":245,"sourceCode":"            return result;\n        } catch (Exception e) {\n            log.error(\"AI text generation service call exception\", e);\n            if (e instanceof BusinessException) {\n                throw e;\n            }\n            throw new BusinessException(ResponseEnum.SYSTEM_ERROR);\n        }\n    }\n\n    /**\n     * Validate text generation parameters\n     */\n    private void validateTextGenerationParams(String question, String domain, int seconds) {\n        if (question == null || question.trim().isEmpty()) {\n            throw new IllegalArgumentException(\"Generation prompt cannot be empty\");\n        }\n        if (domain == null || domain.trim().isEmpty()) {\n            throw new IllegalArgumentException(\"Model domain cannot be empty\");\n        }\n        if (seconds <= 0 || seconds > 300) {\n            throw new IllegalArgumentException(\"Timeout must be between 1-300 seconds\");\n        }\n    }\n\n    /**\n     * Convert AI service error code to corresponding ResponseEnum\n     *\n     * @param errorCode Error code returned by AI service\n     * @return Corresponding ResponseEnum\n     */\n    private ResponseEnum convertTextErrorCodeToResponseEnum(Integer errorCode) {\n        if (errorCode == null) {\n            return ResponseEnum.SYSTEM_ERROR;\n        }\n\n        ResponseEnum responseEnum = TEXT_ERROR_CODE_MAP.get(errorCode);","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/util/BotAIServiceClient.java#L227-L263","documentation":"validateTextGenerationParams rejects a null or blank 'domain' argument with IllegalArgumentException('Model domain cannot be empty'). The domain selects the Spark model (e.g. 'generalv3.5', '4.0Ultra') for the chat parameter block; without it the request would be rejected by the API, so it is validated up front.","triggerScenarios":"generateText(question, null, seconds) or generateText(question, \"\", seconds) or generateText(question, \"   \", seconds) — any caller passing an unset/whitespace domain string.","commonSituations":"Caller derives the domain from a model config that is missing or null (e.g. bot saved without a model field), config key renamed or deleted, or a hardcoded default removed during a model upgrade.","solutions":["Fix the caller to pass a valid non-blank domain matching the TEXT_HOST_URL API version (v4.0)","Add a fallback default domain at the call site when the model config is missing","Validate/normalize model config at bot-save time so domain is never null downstream"],"exampleFix":"// before\nString domain = botModelConfig.getDomain(); // may be null\nbotAIServiceClient.generateText(prompt, domain, 30);\n// after\nString domain = StrUtil.blankToDefault(botModelConfig.getDomain(), \"4.0Ultra\");\nbotAIServiceClient.generateText(prompt, domain, 30);","handlingStrategy":"validation","validationCode":"if (domain == null || domain.trim().isEmpty()) { domain = \"4.0Ultra\"; } // or reject early","typeGuard":null,"tryCatchPattern":"try { return client.generateText(q, domain, 60); } catch (IllegalArgumentException e) { log.warn(\"Invalid text-gen args: {}\", e.getMessage()); return DEFAULT_TEXT; }","preventionTips":["Default the domain when the model config is missing","Validate model config at save time so domain is never null","Keep domain constants aligned with the endpoint API version"],"tags":["java","validation","argument-validation"],"backgroundTag":"missing-required-argument","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"}