{"record":{"id":"dda9b7b49a845373","repo":"theonedev/onedev","slug":"invalid-value-value-for-type-name-va","errorCode":null,"errorMessage":"Invalid value '${value}' for ${type} '${name}'. Valid values are: ${validValues}","messagePattern":"Invalid value '(.+?)' for (.+?) '(.+?)'\\. Valid values are: (.+?)","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"server-core/src/main/java/io/onedev/server/rest/EnumParamConverterProvider.java","lineNumber":41,"sourceCode":"\tpublic <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {\n\t\tif (!rawType.isEnum())\n\t\t\treturn null;\n\n\t\tvar paramInfo = getParamInfo(annotations);\n\t\tvar enumClass = rawType.asSubclass(Enum.class);\n\t\tvar validValues = Arrays.stream(enumClass.getEnumConstants())\n\t\t\t\t.map(Enum::name)\n\t\t\t\t.collect(Collectors.joining(\", \"));\n\n\t\treturn new ParamConverter<>() {\n\t\t\t@Override\n\t\t\tpublic T fromString(String value) {\n\t\t\t\tif (value == null)\n\t\t\t\t\treturn null;\n\t\t\t\ttry {\n\t\t\t\t\treturn (T) Enum.valueOf(enumClass, value.toUpperCase());\n\t\t\t\t} catch (IllegalArgumentException e) {\n\t\t\t\t\tthrow new BadRequestException(buildErrorMessage(paramInfo, value, validValues));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic String toString(T value) {\n\t\t\t\treturn value == null ? null : ((Enum<?>) value).name();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate static String buildErrorMessage(@Nullable ParamInfo paramInfo, String value, String validValues) {\n\t\tif (paramInfo != null)\n\t\t\treturn \"Invalid value '\" + value + \"' for \" + paramInfo.type + \" '\" + paramInfo.name \n\t\t\t\t\t+ \"'. Valid values are: \" + validValues;\n\t\treturn \"Invalid enum value '\" + value + \"'. Valid values are: \" + validValues;\n\t}\n\n\t@Nullable","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/rest/EnumParamConverterProvider.java#L23-L59","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Use one of the values listed in the error message exactly (case-insensitive; input is uppercased before comparison)","Check the enum type's constant names in the OneDev source or API docs for the endpoint","Update scripts/clients if the API enum changed names between versions"],"exampleFix":"// before\nGET /api/projects?sort=asending\n// after\nGET /api/projects?sort=ascending","handlingStrategy":"validation","validationCode":"Set<String> valid = Arrays.stream(MyEnum.values())\n    .map(e -> e.name().toLowerCase())\n    .collect(Collectors.toSet());\nif (value != null && !valid.contains(value.toLowerCase())) {\n    throw new IllegalArgumentException(\"Invalid value: \" + value);\n}","typeGuard":null,"tryCatchPattern":"try {\n    // API call with enum param\n} catch (BadRequestException e) {\n    // parse 'Valid values are:' from message and correct the parameter\n}","preventionTips":["Generate API clients from specs instead of hand-writing enum params","Always send the exact constant name from the enum (case-insensitive)","Check enum values in API docs before use","Re-check enums after upgrading OneDev versions"],"tags":["rest","enum","bad-request"],"backgroundTag":"invalid-enum-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}