{"record":{"id":"4931057d4fe2bded","repo":"iflytek/astron-agent","slug":"param-error-domain-cannot-be-empty","errorCode":"PARAM_ERROR","errorMessage":"domain cannot be empty","messagePattern":"domain cannot be empty","errorType":"validation","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/model/ModelService.java","lineNumber":350,"sourceCode":"        }\n        if (PROVIDER_GOOGLE.equals(provider)) {\n            return completeGooglePath(cleanedPath, modelDomain);\n        }\n        return completeOpenAICompatiblePath(cleanedPath);\n    }\n\n    private String completeAnthropicPath(String cleanedPath) {\n        if (!cleanedPath.matches(\".*/messages/?$\")) {\n            return cleanedPath.matches(\".*/v\\\\d+$\")\n                    ? cleanedPath + \"/messages\"\n                    : cleanedPath + \"/v1/messages\";\n        }\n        return cleanedPath;\n    }\n\n    private String completeGooglePath(String cleanedPath, String modelDomain) {\n        if (StringUtils.isBlank(modelDomain)) {\n            throw new BusinessException(ResponseEnum.PARAM_ERROR, \"domain cannot be empty\");\n        }\n        if (cleanedPath.contains(\":generateContent\")) {\n            return cleanedPath;\n        }\n        if (cleanedPath.contains(\":streamGenerateContent\")) {\n            return cleanedPath.replace(\":streamGenerateContent\", \":generateContent\");\n        }\n        String quotedDomain = Pattern.quote(modelDomain);\n        if (cleanedPath.matches(\".*/v\\\\d+(beta)?/models/\" + quotedDomain + \"/?$\")) {\n            return cleanedPath + \":generateContent\";\n        }\n        if (cleanedPath.matches(\".*/v\\\\d+(beta)?/?$\")) {\n            return cleanedPath + \"/models/\" + modelDomain + \":generateContent\";\n        }\n        return appendPathSegment(cleanedPath, \"/v1beta/models/\" + modelDomain + \":generateContent\");\n    }\n\n    private String completeOpenAICompatiblePath(String cleanedPath) {","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/model/ModelService.java#L332-L368","documentation":"PARAM_ERROR with message 'domain cannot be empty' is thrown by completeGooglePath when completing the API path for the Google (Gemini) provider. Google path completion needs the modelDomain to build the :generateContent endpoint, so a blank domain is rejected before the URL can be composed.","triggerScenarios":"Saving or validating a model with provider=google whose request.getDomain() is null/blank, while the endpoint path lacks :generateContent/:streamGenerateContent, so completeApiPath -> completeGooglePath is reached with an empty domain.","commonSituations":"Frontend form submitted without selecting a model domain; import/migration scripts creating Google models without the domain field; API clients calling the save endpoint directly omitting domain.","solutions":["Set the model domain (e.g. gemini-1.5-pro / gemini-2.0-flash) in the request before saving/validating.","In the console UI, pick the model domain from the dropdown instead of leaving it blank.","If calling the API directly, include the 'domain' field in the payload.","Ensure the provider is google only when a domain is actually available, or choose the matching provider."],"exampleFix":"// before\n{ \"provider\": \"google\", \"endpoint\": \"https://generativelanguage.googleapis.com/v1beta/models\" } // domain missing\n// after\n{ \"provider\": \"google\", \"domain\": \"gemini-1.5-flash\", \"endpoint\": \"https://generativelanguage.googleapis.com/v1beta/models\" }","handlingStrategy":"validation","validationCode":"if (\"google\".equals(provider) && (domain == null || domain.isBlank())) throw new IllegalArgumentException(\"domain is required for google-provider models\");","typeGuard":"boolean hasGoogleDomain(ModelSaveRequest r) { return !\"google\".equals(r.getProvider()) || (r.getDomain() != null && !r.getDomain().isBlank()); }","tryCatchPattern":"try { modelService.validateModel(req); } catch (BusinessException e) { if (\"PARAM_ERROR\".equals(e.getCode()) && String.valueOf(e.getMessage()).contains(\"domain cannot be empty\")) { promptUserToSelectDomain(); } throw e; }","preventionTips":["Make the domain field mandatory in the form when provider=google.","Default the domain to a sensible Gemini model id in API clients.","Validate provider/domain pairing before submitting the request."],"tags":["validation","google","gemini","missing-field"],"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-19T12:17:13.211Z"}