{"record":{"id":"54b6658ec91648bb","repo":"theonedev/onedev","slug":"not-eligible-for-multi-value-54b665","errorCode":null,"errorMessage":"Not eligible for multi-value","messagePattern":"Not eligible for multi-value","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/groupchoiceinput/GroupChoiceInput.java","lineNumber":51,"sourceCode":"\t\tint index = indexes.get(inputSpec.getName());\n\t\tStringBuffer buffer = new StringBuffer();\n\t\tinputSpec.appendField(buffer, index, \"String\");\n\t\tinputSpec.appendCommonAnnotations(buffer, index);\n\t\tif (!inputSpec.isAllowEmpty())\n\t\t\tbuffer.append(\"    @NotEmpty\\n\");\n\t\tinputSpec.appendChoiceProvider(buffer, index, \"@GroupChoice\");\n\t\tinputSpec.appendMethods(buffer, index, \"String\", choiceProvider, defaultValueProvider);\n\t\t\n\t\treturn buffer.toString();\n\t}\n\n\tpublic static Object convertToObject(List<String> strings) {\n\t\tif (strings.size() == 0) \n\t\t\treturn null;\n\t\telse if (strings.size() == 1) \n\t\t\treturn strings.iterator().next();\n\t\telse \n\t\t\tthrow new ValidationException(\"Not eligible for multi-value\");\n\t}\n\n\tpublic static List<String> convertToStrings(Object value) {\n\t\tif (value instanceof String)\n\t\t\treturn Lists.newArrayList((String) value);\n\t\telse\n\t\t\treturn new ArrayList<>();\n\t}\n\n}\n","sourceCodeStart":33,"sourceCodeEnd":62,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/groupchoiceinput/GroupChoiceInput.java#L33-L62","documentation":"GroupChoiceInput.convertToObject maps a single submitted value to the selected group name: empty list yields null, exactly one string is returned as-is. With two or more values it throws ValidationException \"Not eligible for multi-value\" because a group choice input allows selecting only one group.","triggerScenarios":"Calling GroupChoiceInput.convertToObject(List<String>) with a list of 2+ group names, e.g. a form or API submitted multiple values for the same group-choice field.","commonSituations":"A UI control accidentally renders the group choice as multi-select; an automation script passes a list of groups where one is expected; duplicated request parameters arrive under the same input name.","solutions":["Submit exactly one group name, or use a multi-select group input type if multiple groups are required.","Inspect the submitted request/form for duplicated parameter names and deduplicate.","Validate list size (0 or 1) before calling convertToObject.","Check the input definition: set 'multiple: false' rendering, or pick a different input class for multi-select."],"exampleFix":"// before\nObject g = GroupChoiceInput.convertToObject(Lists.newArrayList(\"admins\", \"devs\")); // throws\n\n// after\nList<String> groups = Lists.newArrayList(\"admins\", \"devs\");\nif (groups.size() > 1)\n    throw new ValidationException(\"Please select a single group\");\nObject g = GroupChoiceInput.convertToObject(groups.subList(0, 1));","handlingStrategy":"validation","validationCode":"if (groups != null && groups.size() > 1)\n    throw new ValidationException(\"Please select a single group\");","typeGuard":null,"tryCatchPattern":"try {\n    group = (String) GroupChoiceInput.convertToObject(groups);\n} catch (ValidationException e) {\n    // render single-select hint to user\n}","preventionTips":["Render group choice inputs as single-select (radio/dropdown), not checkbox lists.","Deduplicate request parameters under the same input name.","If multi-group is needed, choose a multi-select input class instead."],"tags":["validation","input-spec","choice-input","multi-value"],"backgroundTag":"invalid-argument-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}