alibaba/nacos · error · NacosApiException
20005
20005
Error message
Prompt version already exists: {version} What it means
Thrown by checkVersionNotExists when resourceManager.findVersion finds an existing row for the given version. Version names must be unique within a prompt. HTTP 409 RESOURCE_CONFLICT (code 20005). Called during createDraft and fork-from-version flows.
Source
Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/prompt/PromptOperationServiceImpl.java:969
if (page == null || page.getPageItems() == null || page.getPageItems().isEmpty()) {
break;
}
all.addAll(page.getPageItems());
if (page.getPageItems().size() < pageSize) {
break;
}
pageNo++;
}
return all;
}
private void checkVersionNotExists(String namespaceId, String promptKey, String version)
throws NacosException {
AiResourceVersion existing =
resourceManager.findVersion(namespaceId, promptKey, RESOURCE_TYPE_PROMPT,
version);
if (existing != null) {
throw new NacosApiException(NacosException.CONFLICT, ErrorCode.RESOURCE_CONFLICT,
"Prompt version already exists: " + version);
}
}
private String resolveNextVersion(String namespaceId, String promptKey) {
List<AiResourceVersion> allVersions = loadAllVersionRows(namespaceId, promptKey);
if (allVersions.isEmpty()) {
return DEFAULT_INITIAL_VERSION;
}
String maxVersion = null;
for (AiResourceVersion v : allVersions) {
if (v == null || !PromptVersionUtils.isValidVersion(v.getVersion())) {
continue;
}
if (maxVersion == null
|| PromptVersionUtils.compareVersion(v.getVersion(), maxVersion) > 0) {
maxVersion = v.getVersion();
}View on GitHub (pinned to 9b989acdf1)
Solutions
- Choose a different, incrementally higher version number (e.g. bump the patch segment).
- Omit targetVersion entirely to let resolveNextVersion auto-assign the next available version.
- List existing versions via getPromptDetail before creating a draft to pick a non-conflicting version.
Example fix
// before service.createDraft(ns, key, null, "1.0.0", template, vars, null); // 1.0.0 exists // after: let server pick next version service.createDraft(ns, key, null, null, template, vars, null); // auto 1.0.1 // or specify explicitly service.createDraft(ns, key, null, "1.0.1", template, vars, null);
Defensive patterns
Strategy: validation
Validate before calling
// Check for existing versions before creating a draft
PromptMetaInfo meta = service.getPromptDetail(ns, key);
if (meta.getVersions().contains(targetVersion)) {
// pick a different version or omit targetVersion for auto-increment
return;
} Type guard
boolean versionIsFree = !service.getPromptDetail(ns, key).getVersions().contains(targetVersion);
Try / catch
try {
service.createDraft(ns, key, basedOn, targetVersion, template, vars, msg);
} catch (NacosApiException e) {
if (e.getErrCode() == NacosException.CONFLICT) {
// version taken — bump and retry
}
throw e;
} Prevention
- Omit targetVersion to let resolveNextVersion auto-assign the next available version.
- In CI pipelines, compute the next version dynamically rather than hardcoding.
- When forking, list existing versions first and choose a non-conflicting target.
When it happens
Trigger: Calling createDraft with a targetVersion that already exists for this prompt; forking from an existing version and specifying a targetVersion that collides with a previously created version.
Common situations: Re-deploying a CI pipeline that hardcodes the same target version; forking without checking existing versions; two concurrent draft creations racing for the same version string.
Related errors
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/0025c491540b9180.
Report an issue: GitHub.