{"record":{"id":"87beeecc806e855b","repo":"theonedev/onedev","slug":"not-eligible-for-multi-value-87beee","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/dateinput/DateInput.java","lineNumber":39,"sourceCode":"\t\tint index = indexes.get(inputSpec.getName());\n\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\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\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":21,"sourceCodeEnd":53,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/dateinput/DateInput.java#L21-L53","documentation":"DateInput.convertToObject converts submitted strings to java.util.Date values by parsing the single string as a long epoch-millisecond value. If more than one value is submitted, it throws a ValidationException since a date input accepts at most one value. IllegalArgumentException (e.g. number format issues) is rethrown as a ValidationException.","triggerScenarios":"Calling DateInput.convertToObject with a collection of strings whose size() is greater than 1; also triggered indirectly when the single submitted value is not parseable as a long epoch milliseconds (caught IllegalArgumentException converted to ValidationException).","commonSituations":"A multi-select UI or script submits an array to a date field; serialization bug duplicating the date string; passing a formatted date string like \"2024-01-01\" instead of epoch milliseconds would hit the number-format branch, not this line.","solutions":["Ensure only one value is submitted for the date input (collection size <= 1).","Set allowMultiple on the input if truly needed (though DateInput is single-value by design; use a different input type for lists).","Fix the caller/form logic that collects more than one date value.","For single values, submit epoch milliseconds as a string, e.g. \"1704067200000\"."],"exampleFix":"// before\nvalue: [\"1704067200000\", \"1704153600000\"]\n// after\nvalue: [\"1704067200000\"]","handlingStrategy":"validation","validationCode":"if (values.size() > 1)\n    throw new IllegalArgumentException(\"Date input accepts at most one value\");\nLong.parseLong(values.iterator().next()); // also validates epoch-millis format","typeGuard":"boolean isSingleEpochMillis(Collection<String> values) {\n    if (values.size() != 1) return false;\n    try { Long.parseLong(values.iterator().next()); return true; }\n    catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try {\n    Date d = DateInput.convertToObject(strings);\n} catch (ValidationException e) {\n    logger.warn(\"Bad date input {}: {}\", strings, e.getMessage());\n    // re-prompt or use default date\n}","preventionTips":["Submit date values as a single-element collection of epoch milliseconds strings.","Never reuse multi-value collectors for DateInput fields.","Validate the value parses as a long before submission.","Use the date picker UI so the format and cardinality are enforced."],"tags":["validation","buildspec","date-input","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-14T00:17:10.932Z"}