{"record":{"id":"a9f444c0f750cacd","repo":"theonedev/onedev","slug":"not-eligible-for-multi-value-a9f444","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/choiceinput/ChoiceInput.java","lineNumber":77,"sourceCode":"\t\t\t\t\treturn strings;\n\t\t\t} else {\n\t\t\t\treturn strings;\n\t\t\t}\n\t\t} else if (strings.size() == 0) {\n\t\t\treturn null;\n\t\t} else if (strings.size() == 1) {\n\t\t\tString value = strings.iterator().next();\n\t\t\tList<String> possibleValues = inputSpec.getPossibleValues();\n\t\t\tif (!possibleValues.isEmpty()) {\n\t\t\t\tif (!possibleValues.contains(value))\n\t\t\t\t\tthrow new ValidationException(\"Invalid choice value\");\n\t\t\t\telse\n\t\t\t\t\treturn value;\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new ValidationException(\"Not eligible for multi-value\");\n\t\t}\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tpublic static List<String> convertToStrings(InputSpec inputSpec, Object value) {\n\t\tList<String> strings = new ArrayList<>();\n\t\tif (inputSpec.isAllowMultiple()) {\n\t\t\tif (inputSpec.checkListElements(value, String.class))\n\t\t\t\tstrings.addAll((List<String>) value);\n\t\t\tCollections.sort(strings);\n\t\t} else if (value instanceof String) {\n\t\t\tstrings.add((String) value);\n\t\t} \n\t\treturn strings;\n\t}\n\n}\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/choiceinput/ChoiceInput.java#L59-L95","documentation":"ChoiceInput.convertToObject rejects collections with more than one value for single-choice inputs. If the input spec has allowMultiple==false and the submitted strings collection has more than one entry, a ValidationException is thrown. A single-choice input accepts zero or one value only.","triggerScenarios":"Calling ChoiceInput.convertToObject on a ChoiceInput whose inputSpec.isAllowMultiple() returns false, with strings.size() > 1 (after the single-value and zero-value branches fall through to the else).","commonSituations":"A UI or script submits multiple selected values while the input is defined as single-choice; a build spec changed allowMultiple from true to false but existing stored parameters still contain multiple values; form serialization bug collecting duplicate values.","solutions":["Set allowMultiple: true on the input if multiple selections are legitimate.","Reduce the submitted collection to a single value matching the single-choice semantics.","Clean up stored job parameters that accumulated multiple values from a previous multi-value configuration.","Check upstream form/serialization logic that duplicates values."],"exampleFix":"// before (spec)\nenvironment:\n  type: choice\n  allowMultiple: false\n  value: [dev, staging]\n// after\n  allowMultiple: true","handlingStrategy":"validation","validationCode":"if (!inputSpec.isAllowMultiple() && strings.size() > 1)\n    throw new IllegalArgumentException(\"Input '\" + inputSpec.getName() + \"' accepts at most one value\");","typeGuard":"boolean isSingleValue(Collection<String> strings, InputSpec spec) {\n    return spec.isAllowMultiple() || strings.size() <= 1;\n}","tryCatchPattern":"try {\n    Object result = ChoiceInput.convertToObject(inputSpec, strings);\n} catch (ValidationException e) {\n    logger.warn(\"Multi-value submitted to single-choice input: {}\", strings);\n    // take first value or reject with user feedback\n}","preventionTips":["Match collection cardinality to the input's allowMultiple setting.","When changing allowMultiple in a spec, clean up previously stored parameter values.","Only send single-element collections for scalar inputs.","Test form serialization so duplicate values are not silently collected."],"tags":["validation","buildspec","multi-value"],"backgroundTag":"mutually-exclusive-options","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"}