theonedev/onedev · error · ValidationException

Not eligible for multi-value

Error message

Not eligible for multi-value

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/datetimeinput/DateTimeInput.java:40

		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");
		buffer.append("    @WithTime\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 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).
  2. Check the input definition in the build spec (.onedev-buildspec.yml) and fix the 'multiple' attribute of the DateTime input.
  3. Before calling convertToObject, validate that the list size is 0 or 1 and reject multi-value lists with a friendly message.
  4. If multiple dates must be kept, change the input type to a type that supports multiple values instead of coercing DateTimeInput.

Example fix

// before
DateTimeInput input = new DateTimeInput("deployDate", true); // multiple=true not intended
Object v = DateTimeInput.convertToObject(Lists.newArrayList("1717000000000", "1717100000000")); // throws

// after
DateTimeInput input = new DateTimeInput("deployDate", false);
List<String> values = Lists.newArrayList("1717000000000");
if (values.size() > 1)
    throw new ValidationException("Please pick a single deploy date");
Object v = DateTimeInput.convertToObject(values);
Defensive patterns

Strategy: validation

Validate before calling

if (values != null && values.size() > 1)
    throw new ValidationException("Date/time input accepts a single value");

Try / catch

try {
    value = DateTimeInput.convertToObject(values);
} catch (ValidationException e) {
    // show e.getMessage() on the form field
}

Prevention

When it happens

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

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

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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