alibaba/spring-ai-alibaba · error · IllegalArgumentException

Unknown dataset status code:

Error message

Unknown dataset status code: 

What it means

versionStatus.fromCode(String) maps a dataset-version status code to the enum and throws IllegalArgumentException "Unknown dataset status code: X" when no constant's code matches. Like the other fromCode guards, it prevents silently creating a bogus enum value from unrecognized data.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/enums/versionStatus.java:39

        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static versionStatus fromCode(String code) {
        for (versionStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown dataset status code: " + code);
    }
} 

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Log the offending code and compare against the codes defined in versionStatus.
  2. Correct the data (DB record or payload) to a valid code.
  3. Add the missing constant if the code is a legitimate new status.
  4. Normalize (trim/lowercase) input before comparison if stored codes vary in format.
  5. Provide a default mapping for legacy codes instead of throwing.

Example fix

// before
throw new IllegalArgumentException("Unknown dataset status code: " + code);
// after
return Arrays.stream(values()).filter(s -> s.getCode().equalsIgnoreCase(code)).findFirst()
    .orElseThrow(() -> new IllegalArgumentException("Unknown dataset status code: " + code + ", valid: " + Arrays.toString(values())));
Defensive patterns

Strategy: try-catch

Validate before calling

boolean valid = Arrays.stream(versionStatus.values())
    .anyMatch(s -> s.getCode().equals(code));

Try / catch

try { st = versionStatus.fromCode(code); } catch (IllegalArgumentException e) { log.warn("Unknown dataset status '{}'", code); st = versionStatus.DRAFT; }

Prevention

When it happens

Trigger: Calling versionStatus.fromCode() with a code absent from the enum, e.g. a corrupted or legacy dataset-version row, a typo in persisted data, or a code written by a newer/older app version.

Common situations: Schema evolution where status codes were renamed; importing dataset versions from another environment; clients sending unexpected status strings; case mismatch in stored codes.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/27871a595fe70ff0. Report an issue: GitHub.