alibaba/spring-ai-alibaba · error · IllegalArgumentException

Invalid status:

Error message

Invalid status: 

What it means

CommonStatus.of() throws IllegalArgumentException when the given status string matches no CommonStatus enum constant. CommonStatus models generic enabled/disabled-style record states, and of() refuses unrecognized values.

Source

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

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

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

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

}

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Pass exactly one of the value strings defined by CommonStatus.
  2. Normalize input (trim, case) before calling of().
  3. Catch IllegalArgumentException at deserialization boundaries and surface a validation error.
  4. Extend the enum if a genuinely new status is required.

Example fix

// before
CommonStatus st = CommonStatus.of("1"); // throws
// after
CommonStatus st = CommonStatus.of("ENABLED"); // match defined value
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

try {
  st = CommonStatus.of(raw);
} catch (IllegalArgumentException e) {
  throw new IllegalArgumentException("Unsupported status; use CommonStatus values", e);
}

Prevention

When it happens

Trigger: Calling CommonStatus.of(status) with a string that is null, empty, or not among the enum's value strings.

Common situations: Booleans ("true"/"1") passed instead of the expected status strings; numeric status codes from legacy schemas; case mismatches.

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