{"record":{"id":"a1204c290a3a3327","repo":"theonedev/onedev","slug":"not-eligible-for-multi-value-a1204c","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/floatinput/FloatInput.java","lineNumber":41,"sourceCode":"\t\tinputSpec.appendCommonAnnotations(buffer, index);\n\t\tif (!inputSpec.isAllowEmpty())\n\t\t\tbuffer.append(\"    @NotNull(message=\\\"May not be empty\\\")\\n\");\n\t\tinputSpec.appendMethods(buffer, index, \"Float\", null, 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\t} else if (strings.size() == 1) {\n\t\t\ttry {\n\t\t\t\treturn Float.valueOf(strings.iterator().next());\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tthrow new ValidationException(\"Invalid float 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\tpublic static List<String> convertToStrings(Object value) {\n\t\tif (value instanceof Float)\n\t\t\treturn Lists.newArrayList(String.valueOf(value));\n\t\telse\n\t\t\treturn new ArrayList<>();\n\t}\n\n}\n","sourceCodeStart":23,"sourceCodeEnd":53,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/floatinput/FloatInput.java#L23-L53","documentation":"FloatInput.convertToObject is a single-value converter: it accepts an empty list (null) or exactly one float string. When the list has two or more elements it throws ValidationException \"Not eligible for multi-value\" because a Float input cannot represent multiple numbers.","triggerScenarios":"Calling FloatInput.convertToObject(List<String>) with 2+ elements; this occurs when a multi-value form field or a list of values is bound to a FloatInput that is not configured as multiple.","commonSituations":"An input defined with 'multiple: true' in the spec is later processed by the single-value path; a form submits repeated values for one input name; a script passes several numbers joined into a list.","solutions":["Submit only one value for the float input, or mark the input 'multiple: true' if multiple values are genuinely required.","Check the build spec definition and align the converter used with the input's multiplicity.","Guard the list size before calling convertToObject and surface a clear user-facing message.","Split or flatten the value list at the caller so each FloatInput receives a single element."],"exampleFix":"// before\nObject f = FloatInput.convertToObject(Lists.newArrayList(\"1.0\", \"2.0\")); // throws\n\n// after\nList<String> vs = Lists.newArrayList(\"1.0\", \"2.0\");\nif (vs.size() > 1)\n    throw new ValidationException(\"Float input accepts a single value\");\nObject f = FloatInput.convertToObject(vs.subList(0, 1));","handlingStrategy":"validation","validationCode":"if (values != null && values.size() > 1)\n    throw new ValidationException(\"Float input accepts a single value\");","typeGuard":null,"tryCatchPattern":"try {\n    f = FloatInput.convertToObject(values);\n} catch (ValidationException e) {\n    // handle multi-value or invalid input per field definition\n}","preventionTips":["Match the input's 'multiple' flag with the converter/consumer used.","Deduplicate repeated form fields sharing the same input name.","Test each input type with 0-, 1-, and 2-element lists."],"tags":["validation","input-spec","single-value","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"}