theonedev/onedev · error · ValidationException

Not eligible for multi-value

Error message

Not eligible for multi-value

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/dateinput/DateInput.java:39

		int index = indexes.get(inputSpec.getName());
		StringBuffer buffer = new StringBuffer();
		inputSpec.appendField(buffer, index, "Date");
		inputSpec.appendCommonAnnotations(buffer, index);
		if (!inputSpec.isAllowEmpty())
			buffer.append("    @NotNull(message=\"May not be empty\")\n");
		inputSpec.appendMethods(buffer, index, "Date", null, defaultValueProvider);
		
		return buffer.toString();
	}

	public static Object convertToObject(List<String> strings) {
		try {
			if (strings.size() == 1)
				return new Date(Long.parseLong(strings.iterator().next()));
			else if (strings.size() == 0)
				return null;
			else
				throw new ValidationException("Not eligible for multi-value");
		} catch (IllegalArgumentException e) {
			throw new ValidationException(e.getMessage());
		}
	}

	public static List<String> convertToStrings(Object value) {
		if (value != null)
			return Lists.newArrayList(String.valueOf(((Date)value).getTime()));
		else
			return new ArrayList<>();
	}

}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Ensure only one value is submitted for the date input (collection size <= 1).
  2. Set allowMultiple on the input if truly needed (though DateInput is single-value by design; use a different input type for lists).
  3. Fix the caller/form logic that collects more than one date value.
  4. For single values, submit epoch milliseconds as a string, e.g. "1704067200000".

Example fix

// before
value: ["1704067200000", "1704153600000"]
// after
value: ["1704067200000"]
Defensive patterns

Strategy: validation

Validate before calling

if (values.size() > 1)
    throw new IllegalArgumentException("Date input accepts at most one value");
Long.parseLong(values.iterator().next()); // also validates epoch-millis format

Type guard

boolean isSingleEpochMillis(Collection<String> values) {
    if (values.size() != 1) return false;
    try { Long.parseLong(values.iterator().next()); return true; }
    catch (NumberFormatException e) { return false; }
}

Try / catch

try {
    Date d = DateInput.convertToObject(strings);
} catch (ValidationException e) {
    logger.warn("Bad date input {}: {}", strings, e.getMessage());
    // re-prompt or use default date
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/87beeecc806e855b. Report an issue: GitHub.