{"record":{"id":"6c20826277cf5941","repo":"theonedev/onedev","slug":"invalid-fields","errorCode":null,"errorMessage":"Invalid fields: ","messagePattern":"Invalid fields: ","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/model/Issue.java","lineNumber":1190,"sourceCode":"\t\t\t\t\t\tif (field instanceof ChoiceField) {\n\t\t\t\t\t\t\tvar choiceField = (ChoiceField) field;\n\t\t\t\t\t\t\tvar possibleValues = choiceField.getPossibleValues();\n\t\t\t\t\t\t\tif (field.isAllowMultiple())\n\t\t\t\t\t\t\t\tinvalidFields.put(fieldName, \"value must not be empty, and should take one or more of: \" + String.join(\", \", possibleValues));\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tinvalidFields.put(fieldName, \"value must not be empty, and should take one of: \" + String.join(\", \", possibleValues));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tinvalidFields.put(fieldName, \"value must not be empty\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (invalidFields.size() > 0) {\n\t\t\t\tvar fieldErrors = new ArrayList<String>();\n\t\t\t\tfor (var entry: invalidFields.entrySet()) {\n\t\t\t\t\tfieldErrors.add(entry.getKey() + \" (\" + entry.getValue() + \")\");\n\t\t\t\t}\n\t\t\t\tthrow new ValidationException(\"Invalid fields: \" + String.join(\", \", fieldErrors));\n\t\t\t}\n\t\t} finally {\n\t\t\tProject.pop();\n\t\t}\n\t}\n\t\n\tpublic List<User> getParticipants() {\n\t\tif (participants == null) {\n\t\t\tparticipants = new LinkedHashSet<>();\n\t\t\tparticipants.add(getSubmitter());\n\t\t\tUserService userService = OneDev.getInstance(UserService.class);\n\t\t\tfor (IssueField field: getFields()) {\n\t\t\t\tif (field.getType().equals(InputSpec.USER)) {\n\t\t\t\t\tif (field.getValue() != null) {\n\t\t\t\t\t\tUser user = userService.findByName(field.getValue());\n\t\t\t\t\t\tif (user != null)\n\t\t\t\t\t\t\tparticipants.add(user);\n\t\t\t\t\t}","sourceCodeStart":1172,"sourceCodeEnd":1208,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/model/Issue.java#L1172-L1208","documentation":"Issue field validation collects errors per field (name -> reason) when populating/applying field values against the project's issue field definitions. If any fields are invalid, a ValidationException listing 'name (reason)' entries is thrown.","triggerScenarios":"Setting issue fields (API, form, script) where a field name is undefined in the project, a required field is missing, a choice value is not in the field's option list, or a value fails the field's type/validation.","commonSituations":"API scripts referencing custom fields not defined in the target project; option values renamed in field settings; importing issues from another project with different custom fields; type mismatches (text vs choice).","solutions":["Fix the field values/names listed in the exception message to match the project's field definitions","Define missing custom fields in Project > Issues > Fields","Update choice fields to use existing option values","Check required fields and supply values for all of them"],"exampleFix":"// before\nfields: {\"Priority\": \"Hign\", \"Env\": \"prod\"}  // typo + undefined field\n// after\nfields: {\"Priority\": \"High\"}  // 'Env' defined or removed","handlingStrategy":"try-catch","validationCode":"for (String name : fields.keySet()) { if (issue.getProject().getIssueSetting().getFieldSpec(name) == null) { /* invalid field */ } }","typeGuard":null,"tryCatchPattern":"try { issue.setFields(fields); } catch (ValidationException e) { reportFieldErrors(e.getMessage()); }","preventionTips":["Validate field names/values against project field definitions before submit","Sync scripts after renaming fields/options","Supply all required field values"],"tags":["issues","validation","fields"],"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"}