{"record":{"id":"31fcd65c6c226b55","repo":"alibaba/nacos","slug":"parameter-missing-31fcd6","errorCode":"PARAMETER_MISSING","errorMessage":"Required parameter 'version' type String is not present","messagePattern":"Required parameter 'version' type String is not present","errorType":"exception","errorClass":"NacosApiException","httpStatus":400,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/form/prompt/PromptPublishForm.java","lineNumber":74,"sourceCode":"    \n    /**\n     * Prompt biz tags (comma-separated, optional).\n     */\n    private String bizTags;\n    \n    /**\n     * Variable definitions with default values (JSON array string, optional).\n     *\n     * <p>Example: [{\"name\":\"question\",\"defaultValue\":\"Hello\",\"description\":\"User question\"}]</p>\n     */\n    private String variables;\n    \n    @Override\n    public void validate() throws NacosApiException {\n        super.validate();\n        \n        if (StringUtils.isEmpty(version)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,\n                \"Required parameter 'version' type String is not present\");\n        }\n        \n        if (!PromptVersionUtils.isValidVersion(version)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM,\n                ErrorCode.PARAMETER_VALIDATE_ERROR,\n                \"Parameter 'version' must be in format 'major.minor.patch' (e.g., '1.0.0')\");\n        }\n    }\n    \n    public String getVersion() {\n        return version;\n    }\n    \n    public void setVersion(String version) {\n        this.version = version;\n    }\n    ","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/form/prompt/PromptPublishForm.java#L56-L92","documentation":"PromptPublishForm.validate() runs `super.validate()` (base prompt fields) then enforces that `version` is present before publishing a new prompt version. Publishing without a version is meaningless because the version is the storage/publishing key, so the server rejects with PARAMETER_MISSING before the format check (error 43) runs.","triggerScenarios":"Calling the prompt publish API (POST /v3/admin/ai/prompts/publish) without a `version` field, or with version=null/empty. The check uses StringUtils.isEmpty so empty-string also fails.","commonSituations":"Assuming the server auto-increments version; frontend publishing form that never collected version; sending `template` and `commitMsg` but forgetting version; migrating from an API that inferred version from content hash.","solutions":["Add a semantic version string in `major.minor.patch` form, e.g. `1.0.0`.","Check existing published versions and bump to a higher version (see PromptVersionUtils.isVersionGreater).","Ensure the publish request body actually serializes the version field (not just sets it in a non-serialized transient field)."],"exampleFix":"// before\n{\"promptKey\":\"hello\",\"template\":\"Hello {{name}}\"}\n// after\n{\"promptKey\":\"hello\",\"version\":\"1.0.0\",\"template\":\"Hello {{name}}\"}","handlingStrategy":"validation","validationCode":"// Before calling prompt publish\nif (version == null || version.isEmpty()) {\n    throw new IllegalArgumentException(\"version is required to publish a prompt\");\n}","typeGuard":"// TypeScript\nconst hasPublishVersion = (v?: string | null): boolean =>\n  v != null && v.length > 0;","tryCatchPattern":"try {\n    form.validate();\n} catch (NacosApiException e) {\n    // collect the version from the user and retry\n}","preventionTips":["Make the version field required in the publish form UI.","Auto-suggest the next semantic version based on existing published versions.","Block the publish button until version is filled."],"tags":["validation","prompt-api","required-field","version","publishing"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}