{"record":{"id":"ae06e380919764c7","repo":"theonedev/onedev","slug":"not-eligible-for-multi-value-ae06e3","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/textinput/TextInput.java","lineNumber":47,"sourceCode":"\t\tif (!inputSpec.isAllowEmpty())\n\t\t\tbuffer.append(\"    @NotEmpty\\n\");\n\t\tif (multiline)\n\t\t\tbuffer.append(\"    @Multiline\\n\");\n\t\tbuffer.append(MessageFormat.format(\"@Size(max={0}, message=\\\"Text is too long. Max {0} characters\\\")\", String.valueOf(MAX_LEN)));\n\t\tif (pattern != null)\n\t\t\tbuffer.append(\"    @Pattern(regexp=\\\"\" + pattern + \"\\\", message=\\\"Should match regular expression: \" + pattern + \"\\\")\\n\");\n\t\tinputSpec.appendMethods(buffer, index, \"String\", null, defaultValueProvider);\n\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\t\n}\n","sourceCodeStart":29,"sourceCodeEnd":58,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/textinput/TextInput.java#L29-L58","documentation":"TextInput.convertToObject is the single-value string converter: empty list becomes null, a one-element list returns that string. With two or more values it throws ValidationException \"Not eligible for multi-value\" because a text input is single-valued and cannot carry a list of strings.","triggerScenarios":"Calling TextInput.convertToObject(List<String>) with 2+ strings; typically a form/API submits multiple values under one text input name, or a 'multiple: true' input is processed by the single-value path.","commonSituations":"Duplicated form fields or duplicated query/body parameters; a workflow previously defined as multi-select changed to a plain text input while old clients still send lists; scripts concatenating values into repeated parameters.","solutions":["Submit only one string for the text input; remove duplicated parameters.","If multiple lines/values are needed, use a textarea-style or multi-value input instead of single TextInput.","Join intended multiple lines into one string (e.g. newline-separated) if that is the desired semantic.","Validate the list size before calling convertToObject."],"exampleFix":"// before\nObject t = TextInput.convertToObject(Lists.newArrayList(\"a\", \"b\")); // throws\n\n// after\nList<String> vs = Lists.newArrayList(\"a\", \"b\");\nObject t = vs.size() > 1\n    ? TextInput.convertToObject(Lists.newArrayList(String.join(\"\\n\", vs)))\n    : TextInput.convertToObject(vs);","handlingStrategy":"validation","validationCode":"if (values != null && values.size() > 1 && !multilineAllowed)\n    throw new ValidationException(\"Text input accepts a single value\");","typeGuard":null,"tryCatchPattern":"try {\n    t = (String) TextInput.convertToObject(values);\n} catch (ValidationException e) {\n    // collapse or reject the multi-value submission\n}","preventionTips":["Ensure form field names are unique so only one value is submitted per text input.","Switch to multi-value or textarea inputs when multiple entries are expected.","Deduplicate query/body parameters server-side before conversion."],"tags":["validation","input-spec","text","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-14T05:17:10.506Z"}