{"record":{"id":"30d882ae7716b9d6","repo":"alibaba/nacos","slug":"version-cannot-be-blank-30d882","errorCode":null,"errorMessage":"Version cannot be blank","messagePattern":"Version cannot be blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/com/alibaba/nacos/api/ai/model/prompt/PromptUtils.java","lineNumber":60,"sourceCode":"    private static final String DOUBLE_UNDERSCORE = \"__\";\n    \n    private PromptUtils() {\n    }\n    \n    /**\n     * Build the Nacos Config group for a specific prompt version.\n     *\n     * @param promptKey prompt key (name)\n     * @param version   version string, e.g. \"1.0.0\"\n     * @return config group string, e.g. \"prompt__{enc_promptKey}__{enc_version}\"\n     * @throws IllegalArgumentException if promptKey or version is blank\n     */\n    public static String buildPromptVersionGroup(String promptKey, String version) {\n        if (StringUtils.isBlank(promptKey)) {\n            throw new IllegalArgumentException(\"Prompt key cannot be blank\");\n        }\n        if (StringUtils.isBlank(version)) {\n            throw new IllegalArgumentException(\"Version cannot be blank\");\n        }\n        return PROMPT_GROUP_PREFIX + NacosAiConfigKeyCodec.encodeVersionedGroupSegment(promptKey)\n            + DOUBLE_UNDERSCORE + NacosAiConfigKeyCodec.encodeVersionedGroupSegment(version);\n    }\n}\n","sourceCodeStart":42,"sourceCodeEnd":66,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/api/src/main/java/com/alibaba/nacos/api/ai/model/prompt/PromptUtils.java#L42-L66","documentation":"PromptUtils.buildPromptVersionGroup throws IllegalArgumentException when the version parameter is blank (null, empty, or whitespace-only). The version is embedded in the group string and must be a non-empty value.","triggerScenarios":"Calling buildPromptVersionGroup with a null or empty version string. Happens when version is derived from a default that was not initialized, or when the caller treats version as optional.","commonSituations":"A prompt version was never assigned before lookup. A form submission omits the version. A default value like null is passed because no specific version was requested.","solutions":["Provide a concrete version string (e.g. '1.0.0') or resolve 'latest' before calling.","Validate version is non-blank at the API boundary.","If the business case allows, default to a known version when none is specified."],"exampleFix":"// before\nString group = PromptUtils.buildPromptVersionGroup(\"myPrompt\", null);\n\n// after\nString version = StringUtils.isBlank(reqVersion) ? \"1.0.0\" : reqVersion;\nString group = PromptUtils.buildPromptVersionGroup(\"myPrompt\", version);","handlingStrategy":"validation","validationCode":"if (StringUtils.isBlank(version)) {\n    throw new IllegalArgumentException(\"version is required\");\n}","typeGuard":"public static boolean isVersionValid(String version) {\n    return version != null && !version.trim().isEmpty();\n}","tryCatchPattern":"try {\n    group = PromptUtils.buildPromptVersionGroup(promptKey, version);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Version cannot be blank\")) {\n        return badRequest(\"version is required\");\n    }\n    throw e;\n}","preventionTips":["Provide or default the version before calling group builders.","Enforce version presence at the controller layer.","Document that version is mandatory for group construction."],"tags":["prompt","validation","blank","config-group","version"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}