theonedev/onedev · error · ValidationException

Invalid boolean value

Error message

Invalid boolean value

What it means

BooleanInput.convertToObject parses user-supplied string values for a boolean job input and throws this validation error when the single value is neither 'true' nor the localized display value of true nor 'false' — i.e. the input text is not a recognized boolean.

Source

Thrown at server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/booleaninput/BooleanInput.java:45

		inputSpec.appendField(buffer, index, "Boolean");
		inputSpec.appendCommonAnnotations(buffer, index);
		buffer.append("    @NotNull(message=\"May not be empty\")\n");
		inputSpec.appendMethods(buffer, index, "Boolean", null, defaultValueProvider);
		
		return buffer.toString();
	}

	public static Object convertToObject(List<String> strings) {
		if (strings.size() == 0) {
			return false;
		} else if (strings.size() == 1) {
			String string = strings.iterator().next();
			if (string.equalsIgnoreCase("true") || string.equalsIgnoreCase(TextUtils.getDisplayValue(true)))
				return true;
			else if (string.equalsIgnoreCase("false") || string.equalsIgnoreCase(TextUtils.getDisplayValue(false)))
				return false;
			else
				throw new ValidationException("Invalid boolean value");
		} else {
			throw new ValidationException("Not eligible for multi-value");
		}
	}

	public static List<String> convertToStrings(Object value) {
		if (value instanceof Boolean)
			return Lists.newArrayList(TextUtils.getDisplayValue((Boolean)value));
		else
			return Lists.newArrayList(TextUtils.getDisplayValue(false));
	}

}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Use the literal strings 'true' or 'false' (any casing) for the boolean input value.
  2. Normalize alternative spellings ('yes'/'no', '1'/'0', 'on'/'off') to true/false before the call.
  3. Trim whitespace and check for invisible characters in the spec value.

Example fix

// before
Object value = BooleanInput.convertToObject(Lists.newArrayList("yes"));

// after
Object value = BooleanInput.convertToObject(Lists.newArrayList("true"));
Defensive patterns

Strategy: validation

Validate before calling

boolean validBooleanString(String s) {
    if (s == null) return false;
    s = s.trim();
    return s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false");
}

Type guard

boolean isBooleanLiteral(String s) {
    return "true".equalsIgnoreCase(s) || "false".equalsIgnoreCase(s);
}

Try / catch

try {
    Object flag = BooleanInput.convertToObject(Lists.newArrayList(value));
} catch (ValidationException e) {
    // value must be 'true' or 'false' (case-insensitive)
}

Prevention

When it happens

Trigger: Calling BooleanInput.convertToObject with a one-element list whose string is not 'true', 'false', nor TextUtils.getDisplayValue(true/false) (case-insensitive), e.g. 'yes', '1', 'TRUE ' with trailing space, or 'enabled'.

Common situations: Buildspec or job boolean input populated by hand or by a script using shell-style 'yes/no' or 0/1 conventions; values exported from another tool with different boolean spellings; whitespace or encoding issues in edited spec files.

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/6a79a3f4a0a28a3b. Report an issue: GitHub.