alibaba/spring-ai-alibaba · error · IllegalArgumentException

Invalid status:

Error message

Invalid status: 

What it means

AppStatus.of throws IllegalArgumentException when no enum constant matches the numeric status code in AppStatus.values() — the DB/value source contains a status integer outside the defined set, typically from schema drift or corrupt data.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-runtime/src/main/java/com/alibaba/cloud/ai/studio/runtime/enums/AppStatus.java:61

	@EnumValue
	private final Integer status; // Numeric status code

	private final String value; // String representation of the status

	/**
	 * Converts a numeric status code to its corresponding AppStatus enum value.
	 * @param status Numeric status code
	 * @return Corresponding AppStatus enum value
	 * @throws IllegalArgumentException if the status code is invalid
	 */
	public static AppStatus of(Integer status) {
		for (AppStatus appStatus : AppStatus.values()) {
			if (appStatus.status.equals(status)) {
				return appStatus;
			}
		}

		throw new IllegalArgumentException("Invalid status: " + status);
	}

}

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Use a status string that matches one of AppStatus's constant values exactly.
  2. Trim/case-normalize the incoming string before conversion.
  3. Handle IllegalArgumentException from of() when input is user- or DB-sourced.
  4. Migrate stored data if statuses were renamed across versions.

Example fix

// before
AppStatus st = AppStatus.of("running"); // throws if not defined
// after
AppStatus st = AppStatus.of("published"); // verify against enum values
Defensive patterns

Strategy: validation

Validate before calling

boolean valid = Arrays.stream(AppStatus.values())
    .anyMatch(s -> s.getStatus().equals(candidate));

Type guard

Optional<AppStatus> tryAppStatus(String s) {
  try { return Optional.of(AppStatus.of(s)); }
  catch (IllegalArgumentException e) { return Optional.empty(); }
}

Try / catch

try {
  st = AppStatus.of(raw);
} catch (IllegalArgumentException e) {
  st = AppStatus.DRAFT; // or reject with a validation error
}

Prevention

When it happens

Trigger: Calling AppStatus.of(status) with null, empty, or a value outside the enum's defined statuses.

Common situations: Legacy app records persisted with statuses later renamed; clients sending enums by name instead of the expected value string; copy-paste of status strings between different enum types (e.g. CommonStatus values).

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/a7d7e42a64a95f73. Report an issue: GitHub.