alibaba/nacos · error · NacosApiException
10000
10000
Error message
Either 'basedOnVersion' or 'template' must be provided
What it means
Thrown by PromptDraftCreateForm.validate() when BOTH basedOnVersion and template are blank. A draft must originate from either an existing version (basedOnVersion) or a fresh template string — at least one is required. super.validate() (promptKey) runs first. Maps to code 10000 (PARAMETER_MISSING), HTTP 400.
Source
Thrown at ai/src/main/java/com/alibaba/nacos/ai/form/prompt/PromptDraftCreateForm.java:57
private String basedOnVersion;
private String targetVersion;
private String template;
private String variables;
private String commitMsg;
private String description;
private String bizTags;
@Override
public void validate() throws NacosApiException {
super.validate();
if (StringUtils.isBlank(basedOnVersion) && StringUtils.isBlank(template)) {
throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,
"Either 'basedOnVersion' or 'template' must be provided");
}
}
public String getBasedOnVersion() {
return basedOnVersion;
}
public void setBasedOnVersion(String basedOnVersion) {
this.basedOnVersion = basedOnVersion;
}
public String getTargetVersion() {
return targetVersion;
}
public void setTargetVersion(String targetVersion) {
this.targetVersion = targetVersion;View on GitHub (pinned to 9b989acdf1)
Solutions
- Provide either basedOnVersion (to fork an existing version) or template (raw prompt template text).
- For a brand-new prompt, send template with your starting text.
- Verify promptKey is also present.
Example fix
// before
promptKey=myPrompt
// after
promptKey=myPrompt&template=Hello {{name}} Defensive patterns
Strategy: validation
Validate before calling
boolean hasBasedOn = basedOnVersion != null && !basedOnVersion.trim().isEmpty();
boolean hasTemplate = template != null && !template.trim().isEmpty();
if (!hasBasedOn && !hasTemplate) {
throw new IllegalArgumentException("basedOnVersion or template required");
} Type guard
static boolean hasDraftSource(String basedOnVersion, String template) {
return (basedOnVersion != null && !basedOnVersion.isBlank())
|| (template != null && !template.isBlank());
} Try / catch
catch (NacosApiException e) {
if (e.getErrCode() == 10000 && e.getMessage().contains("basedOnVersion")) { /* add source */ }
} Prevention
- For new prompts always seed a template string.
- For forks, pass basedOnVersion pointing at the source version.
When it happens
Trigger: Calling POST to create a prompt draft (PromptAdminController.createDraft) with promptKey set but neither basedOnVersion nor template.
Common situations: 'New from scratch' UI path forgets to seed an empty template; client sends only metadata (variables/commitMsg/description) without a source; refactoring splits the fields and drops one branch.
Related errors
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/4fe1031654eaf86c.
Report an issue: GitHub.