alibaba/nacos · error · NacosApiException

20002

20002

Error message

Current editing version is not draft: {version}

What it means

Thrown by requireDraftVersion when the resolved version row is null OR its status is not 'draft'. Used by operations that only make sense against an in-progress draft (e.g. editing content before submit). Maps to INVALID_PARAM (20002) even when the row is missing, because the precondition (a draft exists) is what failed.

Source

Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/resource/AiResourceManager.java:698

        String version,
        String status, String description, String storageJson) {
        aiResourceVersionPersistService.updateStorageAndDesc(namespaceId, name, type, version,
            storageJson, description);
        aiResourceVersionPersistService.updateStatus(namespaceId, name, type, version, status);
    }
    
    /**
     * Find a version row and verify it is in draft status.
     *
     * @throws NacosApiException if version not found or not in draft status
     */
    public AiResourceVersion requireDraftVersion(String namespaceId, String name, String type,
        String version)
        throws NacosException {
        AiResourceVersion v =
            aiResourceVersionPersistService.find(namespaceId, name, type, version);
        if (v == null || !isDraftVersion(v)) {
            throw new NacosApiException(NacosException.INVALID_PARAM,
                ErrorCode.PARAMETER_VALIDATE_ERROR,
                "Current editing version is not draft: " + version);
        }
        return v;
    }
    
    /**
     * Find a version row and verify it can be submitted.
     *
     * <p>Submit accepts a draft version for review, a reviewing version as an idempotent
     * no-op, or a reviewed version for resubmission. Online and offline versions are
     * rejected.</p>
     *
     * @throws NacosApiException if version not found or not in a submittable status
     */
    public AiResourceVersion requireSubmitVersion(String namespaceId, String name, String type,
        String version)
        throws NacosException {

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Re-fetch the resource's version info to see the current status of the named version.
  2. If the version advanced past draft, create a new draft from the latest base version instead of editing the old one.
  3. If the version name is wrong, correct it to the actual current editing version.
  4. Ensure no concurrent workflow is mutating the same draft between fetch and update.

Example fix

// before: editing a version that was already submitted
manager.requireDraftVersion(ns, name, type, "v1.0"); // throws
// after: re-read version info and create a fresh draft from latest
String draftVersion = manager.createDraft(ns, name, type, /*basedOnVersion*/ null);
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the version is a draft before invoking a draft-only operation.
AiResourceVersion v = aiResourceVersionPersistService.find(ns, name, type, version);
if (v == null || !"draft".equalsIgnoreCase(v.getStatus())) {
    return rejectDraft(version);
}

Try / catch

try {
    return manager.requireDraftVersion(ns, name, type, version);
} catch (NacosApiException e) {
    if (e.getErrCode() == NacosException.INVALID_PARAM
        && e.getMessage().contains("not draft")) {
        // refresh version info and create a new draft from latest
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling an edit/update-draft API with a version name that does not exist, or with a version whose status has already moved on to 'reviewing', 'reviewed', 'online', or 'offline'. Also when two concurrent callers advance the same draft out of draft status.

Common situations: Stale client that cached a draft version name after it was submitted; version lifecycle advanced server-side (review/publish) while client still believes it is a draft; typo in version name.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/aaaafc940201cddb. Report an issue: GitHub.