theonedev/onedev · error · ValidationException

Not eligible for multi-value

Error message

Not eligible for multi-value

What it means

GroupChoiceInput.convertToObject maps a single submitted value to the selected group name: empty list yields null, exactly one string is returned as-is. With two or more values it throws ValidationException "Not eligible for multi-value" because a group choice input allows selecting only one group.

Source

Thrown at server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/groupchoiceinput/GroupChoiceInput.java:51

		int index = indexes.get(inputSpec.getName());
		StringBuffer buffer = new StringBuffer();
		inputSpec.appendField(buffer, index, "String");
		inputSpec.appendCommonAnnotations(buffer, index);
		if (!inputSpec.isAllowEmpty())
			buffer.append("    @NotEmpty\n");
		inputSpec.appendChoiceProvider(buffer, index, "@GroupChoice");
		inputSpec.appendMethods(buffer, index, "String", choiceProvider, defaultValueProvider);
		
		return buffer.toString();
	}

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

	public static List<String> convertToStrings(Object value) {
		if (value instanceof String)
			return Lists.newArrayList((String) value);
		else
			return new ArrayList<>();
	}

}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Submit exactly one group name, or use a multi-select group input type if multiple groups are required.
  2. Inspect the submitted request/form for duplicated parameter names and deduplicate.
  3. Validate list size (0 or 1) before calling convertToObject.
  4. Check the input definition: set 'multiple: false' rendering, or pick a different input class for multi-select.

Example fix

// before
Object g = GroupChoiceInput.convertToObject(Lists.newArrayList("admins", "devs")); // throws

// after
List<String> groups = Lists.newArrayList("admins", "devs");
if (groups.size() > 1)
    throw new ValidationException("Please select a single group");
Object g = GroupChoiceInput.convertToObject(groups.subList(0, 1));
Defensive patterns

Strategy: validation

Validate before calling

if (groups != null && groups.size() > 1)
    throw new ValidationException("Please select a single group");

Try / catch

try {
    group = (String) GroupChoiceInput.convertToObject(groups);
} catch (ValidationException e) {
    // render single-select hint to user
}

Prevention

When it happens

Trigger: Calling GroupChoiceInput.convertToObject(List<String>) with a list of 2+ group names, e.g. a form or API submitted multiple values for the same group-choice field.

Common situations: A UI control accidentally renders the group choice as multi-select; an automation script passes a list of groups where one is expected; duplicated request parameters arrive under the same input name.

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/54b6658ec91648bb. Report an issue: GitHub.