{"record":{"id":"aea99302d5de0dad","repo":"theonedev/onedev","slug":"error-validating-value-displayvalue-of-field","errorCode":null,"errorMessage":"Error validating value '${displayValue}' of field '${fieldName}': ${message}","messagePattern":"Error validating value '(.+?)' of field '(.+?)': (.+?)","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/model/support/issue/field/FieldUtils.java","lineNumber":180,"sourceCode":"\t\t\t} finally {\n\t\t\t\tHierarchicalContext.pop();\n\t\t\t}\n\t\t}\n\t\treturn fieldValues;\n\t}\n\t\n\tprivate static void validateFieldValue(FieldSpec fieldSpec, String fieldName, List<String> fieldValue) {\n\t\ttry {\n\t\t\tfieldSpec.convertToObject(fieldValue);\n\t\t} catch (Exception e) {\n\t\t\tString displayValue;\n\t\t\tif (fieldSpec instanceof SecretField)\n\t\t\t\tdisplayValue = SecretInput.MASK;\n\t\t\telse\n\t\t\t\tdisplayValue = fieldValue.toString();\n\t\t\tif (e.getMessage() == null)\n\t\t\t\tlogger.error(\"Error validating field value\", e);\n\t\t\tthrow new ValidationException(\"Error validating value '\" + displayValue + \"' of field '\" \n\t\t\t\t\t+ fieldName + \"': \" + e.getMessage());\n\t\t}\n\t}\n\n\tprivate static void validateFieldNames(Collection<String> fieldSpecNames, Collection<String> fieldNames) {\n\t\tfor (String fieldSpecName: fieldSpecNames) {\n\t\t\tif (!fieldNames.contains(fieldSpecName))\n\t\t\t\tthrow new ValidationException(\"Missing issue field: \" + fieldSpecName);\n\t\t}\n\t\tfor (String fieldName: fieldNames) {\n\t\t\tif (!fieldSpecNames.contains(fieldName))\n\t\t\t\tthrow new ValidationException(\"Unknown issue field: \" + fieldName);\n\t\t}\n\t}\n\t\n\tpublic static void validateFieldMap(Map<String, FieldSpec> fieldSpecMap, Map<String, List<String>> fieldMap) {\n\t\tvalidateFieldNames(fieldSpecMap.keySet(), fieldMap.keySet());\n\t\tfor (Map.Entry<String, List<String>> entry: fieldMap.entrySet()) {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/model/support/issue/field/FieldUtils.java#L162-L198","documentation":"validateFieldValue catches exceptions thrown while validating a single issue field value and rethrows a ValidationException that includes the field name, the display value, and the underlying message. It indicates the supplied value failed the field spec's validation (choice options, date format, etc.).","triggerScenarios":"Calling validateFieldMap/validateFields with a value that fails FieldSpec validation, e.g. a choice field value not in the option list, an invalid date string, or a malformed number; secret fields show MASK as display value.","commonSituations":"REST API issue creation with wrong custom field values; scripts copying values between projects whose field definitions differ; users typing free text into choice fields.","solutions":["Read the embedded ${message} for the concrete validation reason and fix the value accordingly","For choice fields, use one of the exact option values defined in the field spec","Validate values with fieldSpec.convertToObject() locally before submitting"],"exampleFix":"// before\nfieldMap.put(\"Priority\", List.of(\"very-high\")); // not an option\n// after\nfieldMap.put(\"Priority\", List.of(\"High\")); // exact option name from field spec","handlingStrategy":"validation","validationCode":"Object converted = fieldSpec.convertToObject(raw);\nfieldSpec.validate(converted); // throws early with detailed message","typeGuard":null,"tryCatchPattern":"try {\n    FieldUtils.validateFieldMap(fieldSpecMap, fieldMap);\n} catch (ValidationException e) {\n    showErrorToUser(e.getMessage()); // already contains field, value and reason\n}","preventionTips":["Fetch option lists from the field spec rather than hardcoding values","Validate values client-side with fieldSpec.convertToObject before submitting","Sync field definitions when copying issues between projects"],"tags":["validation","issue-fields","api"],"backgroundTag":"schema-validation-failed","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"}