theonedev/onedev · error · ValidationException
Invalid integer value
Error message
Invalid integer value
What it means
IntegerInput.convertToObject parses a single submitted string into an Integer via Integer.valueOf. On NumberFormatException it throws ValidationException "Invalid integer value" because the value is not a valid 32-bit integer literal (non-numeric, decimal point, empty, or out of Integer range).
Source
Thrown at server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/integerinput/IntegerInput.java:47
} else {
buffer.append(" @Range(min=" + minValue.toString() + "L)\n");
}
} else if (maxValue != null) {
buffer.append(" @Range(max=" + maxValue.toString() + "L)\n");
}
inputSpec.appendMethods(buffer, index, "Integer", null, defaultValueProvider);
return buffer.toString();
}
public static Object convertToObject(List<String> strings) {
if (strings.size() == 0) {
return null;
} else if (strings.size() == 1) {
try {
return Integer.valueOf(strings.iterator().next());
} catch (NumberFormatException e) {
throw new ValidationException("Invalid integer value");
}
} else {
throw new ValidationException("Not eligible for multi-value");
}
}
public static List<String> convertToStrings(Object value) {
if (value instanceof Integer)
return Lists.newArrayList(String.valueOf(value));
else
return new ArrayList<>();
}
}
View on GitHub (pinned to d44925c47c)
Solutions
- Correct the value to a whole number within 32-bit range, e.g. "42", "-7".
- Validate with a regex like -?\d+ before submission and reject decimals explicitly.
- If the source value is a float, round/truncate it deliberately (e.g. (int) Float.parseFloat(v)) before passing it.
- Check for empty variables in scripts that interpolate into the input value.
Example fix
// before
String v = env.get("REPLICAS"); // "2.5"
Object i = IntegerInput.convertToObject(Lists.newArrayList(v)); // throws
// after
String v = env.get("REPLICAS");
if (!v.matches("-?\\d+"))
throw new ValidationException("Replicas must be a whole number");
Object i = IntegerInput.convertToObject(Lists.newArrayList(v)); Defensive patterns
Strategy: validation
Validate before calling
if (value != null && !value.matches("-?\\d+"))
throw new ValidationException("Value must be a whole number"); Try / catch
try {
i = IntegerInput.convertToObject(Lists.newArrayList(value));
} catch (ValidationException e) {
// invalid integer: correct value or apply default
} Prevention
- Reject decimal points and thousands separators before submission.
- Check int range (Integer.MIN_VALUE..Integer.MAX_VALUE) for large numbers.
- Guard interpolated variables against being empty or textual.
When it happens
Trigger: Calling IntegerInput.convertToObject(List<String>) with a single element like "abc", "3.14", "", "99999999999" (out of int range).
Common situations: User enters a decimal number in an integer field; a script substitutes an empty or text variable; a long/float value from another system is submitted to an integer input.
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
- Invalid float value
- Not eligible for multi-value
- Not eligible for multi-value
- Not eligible for multi-value
- Not eligible for multi-value
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/648bfc63d6e10211.
Report an issue: GitHub.