theonedev/onedev · warning · BadRequestException

Invalid value '${value}' for ${type} '${name}'. Valid values

Error message

Invalid value '${value}' for ${type} '${name}'. Valid values are: ${validValues}

What it means

EnumParamConverterProvider builds JAX-RS param converters for enum types. fromString() uppercases the raw string and calls Enum.valueOf(); if the value is not a valid constant name, it throws BadRequestException with 'Invalid value ... for <type> <name>. Valid values are: ...'. This is a client-side request error listing the accepted enum values.

Source

Thrown at server-core/src/main/java/io/onedev/server/rest/EnumParamConverterProvider.java:41

	public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
		if (!rawType.isEnum())
			return null;

		var paramInfo = getParamInfo(annotations);
		var enumClass = rawType.asSubclass(Enum.class);
		var validValues = Arrays.stream(enumClass.getEnumConstants())
				.map(Enum::name)
				.collect(Collectors.joining(", "));

		return new ParamConverter<>() {
			@Override
			public T fromString(String value) {
				if (value == null)
					return null;
				try {
					return (T) Enum.valueOf(enumClass, value.toUpperCase());
				} catch (IllegalArgumentException e) {
					throw new BadRequestException(buildErrorMessage(paramInfo, value, validValues));
				}
			}

			@Override
			public String toString(T value) {
				return value == null ? null : ((Enum<?>) value).name();
			}
		};
	}

	private static String buildErrorMessage(@Nullable ParamInfo paramInfo, String value, String validValues) {
		if (paramInfo != null)
			return "Invalid value '" + value + "' for " + paramInfo.type + " '" + paramInfo.name 
					+ "'. Valid values are: " + validValues;
		return "Invalid enum value '" + value + "'. Valid values are: " + validValues;
	}

	@Nullable

View on GitHub (pinned to d44925c47c)

Solutions

  1. Use one of the values listed in the error message exactly (case-insensitive; input is uppercased before comparison)
  2. Check the enum type's constant names in the OneDev source or API docs for the endpoint
  3. Update scripts/clients if the API enum changed names between versions

Example fix

// before
GET /api/projects?sort=asending
// after
GET /api/projects?sort=ascending
Defensive patterns

Strategy: validation

Validate before calling

Set<String> valid = Arrays.stream(MyEnum.values())
    .map(e -> e.name().toLowerCase())
    .collect(Collectors.toSet());
if (value != null && !valid.contains(value.toLowerCase())) {
    throw new IllegalArgumentException("Invalid value: " + value);
}

Try / catch

try {
    // API call with enum param
} catch (BadRequestException e) {
    // parse 'Valid values are:' from message and correct the parameter
}

Prevention

When it happens

Trigger: Passing an unknown, misspelled, or wrongly-cased value for an enum query/path parameter in the REST API, e.g. ?order=asending instead of ASCENDING (input is uppercased, but must match a constant name after that).

Common situations: Hand-written API calls or scripts with typos; API version changes renaming/removing enum constants; sending lowercase/abbreviated values not present in the enum; copy-pasting values from a different endpoint's enum.

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 theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/dda9b7b49a845373. Report an issue: GitHub.