{"record":{"id":"3850c523fdc5cfa6","repo":"theonedev/onedev","slug":"not-eligible-for-multi-value-3850c5","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/datetimeinput/DateTimeInput.java","lineNumber":40,"sourceCode":"\t\tStringBuffer buffer = new StringBuffer();\n\t\tinputSpec.appendField(buffer, index, \"Date\");\n\t\tinputSpec.appendCommonAnnotations(buffer, index);\n\t\tif (!inputSpec.isAllowEmpty())\n\t\t\tbuffer.append(\"    @NotNull(message=\\\"May not be empty\\\")\\n\");\n\t\tbuffer.append(\"    @WithTime\\n\");\n\t\tinputSpec.appendMethods(buffer, index, \"Date\", null, defaultValueProvider);\n\t\t\n\t\treturn buffer.toString();\n\t}\n\n\tpublic static Object convertToObject(List<String> strings) {\n\t\ttry {\n\t\t\tif (strings.size() == 1)\n\t\t\treturn new Date(Long.parseLong(strings.iterator().next()));\n\t\t\telse if (strings.size() == 0)\n\t\t\t\treturn null;\n\t\t\telse\n\t\t\t\tthrow new ValidationException(\"Not eligible for multi-value\");\n\t\t} catch (IllegalArgumentException e) {\n\t\t\tthrow new ValidationException(e.getMessage());\n\t\t}\n\t}\n\n\tpublic static List<String> convertToStrings(Object value) {\n\t\tif (value != null)\n\t\t\treturn Lists.newArrayList(String.valueOf(((Date)value).getTime()));\n\t\telse\n\t\t\treturn new ArrayList<>();\n\t}\n\n}\n","sourceCodeStart":22,"sourceCodeEnd":54,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/datetimeinput/DateTimeInput.java#L22-L54","documentation":"DateTimeInput.convertToObject is a single-value converter for date/time input fields: it accepts a list with exactly one element (a millisecond-epoch string) or an empty list (null). If the list contains two or more values, it throws ValidationException \"Not eligible for multi-value\" because a DateTime input is defined as single-value and cannot represent multiple dates.","triggerScenarios":"Calling DateTimeInput.convertToObject(List<String>) with a list of 2+ strings; this happens when an input field defined as multi-value (or with multiple submitted values) is bound to a DateTimeInput whose 'multiple' setting is false.","commonSituations":"A build spec job defines a date input but a job template or form submits several values for it; a user passes a list of dates to an API that expects a single-value input; someone reuses a multi-value converter result with a single-value input type.","solutions":["Ensure the input is submitted with at most one value, or set 'multiple: true' on the input if multiple dates are actually needed (which switches to DateTimeInput's multi-value handling if available).","Check the input definition in the build spec (.onedev-buildspec.yml) and fix the 'multiple' attribute of the DateTime input.","Before calling convertToObject, validate that the list size is 0 or 1 and reject multi-value lists with a friendly message.","If multiple dates must be kept, change the input type to a type that supports multiple values instead of coercing DateTimeInput."],"exampleFix":"// before\nDateTimeInput input = new DateTimeInput(\"deployDate\", true); // multiple=true not intended\nObject v = DateTimeInput.convertToObject(Lists.newArrayList(\"1717000000000\", \"1717100000000\")); // throws\n\n// after\nDateTimeInput input = new DateTimeInput(\"deployDate\", false);\nList<String> values = Lists.newArrayList(\"1717000000000\");\nif (values.size() > 1)\n    throw new ValidationException(\"Please pick a single deploy date\");\nObject v = DateTimeInput.convertToObject(values);","handlingStrategy":"validation","validationCode":"if (values != null && values.size() > 1)\n    throw new ValidationException(\"Date/time input accepts a single value\");","typeGuard":null,"tryCatchPattern":"try {\n    value = DateTimeInput.convertToObject(values);\n} catch (ValidationException e) {\n    // show e.getMessage() on the form field\n}","preventionTips":["Keep 'multiple: false' inputs bound to single-value form controls only.","Deduplicate submitted parameter values before conversion.","Write a unit test feeding a 2-element list to each single-value converter."],"tags":["validation","input-spec","single-value","datetime"],"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"}