theonedev/onedev · error · ValidationException
Invalid float value
Error message
Invalid float value
What it means
FloatInput.convertToObject parses a single submitted string into a Float via Float.valueOf. When parsing fails (NumberFormatException), it throws ValidationException "Invalid float value" because the submitted value is not a valid float literal (empty, non-numeric, out of float range, wrong locale separators).
Source
Thrown at server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/floatinput/FloatInput.java:38
int index = indexes.get(inputSpec.getName());
StringBuffer buffer = new StringBuffer();
inputSpec.appendField(buffer, index, "Float");
inputSpec.appendCommonAnnotations(buffer, index);
if (!inputSpec.isAllowEmpty())
buffer.append(" @NotNull(message=\"May not be empty\")\n");
inputSpec.appendMethods(buffer, index, "Float", 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 Float.valueOf(strings.iterator().next());
} catch (NumberFormatException e) {
throw new ValidationException("Invalid float value");
}
} else {
throw new ValidationException("Not eligible for multi-value");
}
}
public static List<String> convertToStrings(Object value) {
if (value instanceof Float)
return Lists.newArrayList(String.valueOf(value));
else
return new ArrayList<>();
}
}
View on GitHub (pinned to d44925c47c)
Solutions
- Correct the submitted value to a valid float literal such as "3.14", "-2", "1e3".
- Validate the value client-side (regex like -?\d+(\.\d+)?([eE][+-]?\d+)?) before submitting.
- If the value comes from a variable, check it is not empty at the point of interpolation.
- Use a dot as the decimal separator regardless of locale.
Example fix
// before
String v = props.get("threshold"); // "1,5"
Object f = FloatInput.convertToObject(Lists.newArrayList(v)); // ValidationException
// after
String v = props.get("threshold").replace(',', '.');
if (!v.matches("-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?"))
throw new ValidationException("Threshold must be a number");
Object f = FloatInput.convertToObject(Lists.newArrayList(v)); Defensive patterns
Strategy: validation
Validate before calling
if (value != null && !value.matches("-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?"))
throw new ValidationException("Value must be a valid float"); Try / catch
try {
f = FloatInput.convertToObject(Lists.newArrayList(value));
} catch (ValidationException e) {
// invalid float: re-prompt or default
} Prevention
- Always use '.' as decimal separator before submitting.
- Sanitize interpolated shell/environment variables used as float inputs.
- Validate numeric fields client-side with a float regex.
When it happens
Trigger: Calling FloatInput.convertToObject(List<String>) with a single-element list whose string is not parseable by Float.valueOf, e.g. "abc", "", "1,5", "1e999".
Common situations: User types text or a comma decimal separator into a float input field; a script interpolates an empty variable into a build spec float input; locale-formatted numbers with thousands separators submitted through the API.
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 integer 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/d0fe7c77b12ea602.
Report an issue: GitHub.