theonedev/onedev · error · ValidationException
Invalid build id/number
Error message
Invalid build id/number
What it means
BuildChoiceInput converts user-supplied form strings into build ids (Long) for build-choice input parameters. Any string that is not a valid Long raises a NumberFormatException, which is rethrown as ValidationException('Invalid build id/number').
Source
Thrown at server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/BuildChoiceInput.java:43
buffer.append(" @BuildChoice(useNumber=true)\n");
if (inputSpec.isAllowMultiple())
inputSpec.appendMethods(buffer, index, "List<Long>", null, null);
else
inputSpec.appendMethods(buffer, index, "Long", null, null);
return buffer.toString();
}
public static Object convertToObject(InputSpec inputSpec, List<String> strings) {
try {
if (inputSpec.isAllowMultiple())
return strings.stream().map(it->Long.valueOf(it)).collect(Collectors.toList());
else if (strings.size() == 0)
return null;
else
return Long.valueOf(strings.iterator().next());
} catch (NumberFormatException e) {
throw new ValidationException("Invalid build id/number");
}
}
public static List<String> convertToStrings(InputSpec inputSpec, Object value) {
if (value instanceof List)
return ((List<?>)value).stream().map(it->it.toString()).collect(Collectors.toList());
else if (value instanceof Long)
return Lists.newArrayList(value.toString());
else
return new ArrayList<>();
}
}
View on GitHub (pinned to d44925c47c)
Solutions
- Enter the numeric build id or number only (e.g. 42, not #42).
- Use the build picker UI instead of free-typing the value.
- Fix the parameter's default value in the build spec to a valid numeric build reference.
- If referencing builds across projects, verify the referenced build exists and use ${} property substitution that resolves to a number.
Example fix
// before (parameter value) value: "#123" // after value: "123"
Defensive patterns
Strategy: validation
Validate before calling
// JS/Java check before submitting
function isValidBuildRef(v) { return /^\d+$/.test(String(v).trim()); }
if (!isValidBuildRef(inputValue)) throw new Error("Build reference must be a numeric id/number"); Type guard
boolean isNumericBuildRef(Object v) {
return v instanceof String && ((String) v).trim().matches("\\d+");
} Try / catch
try {
Object build = input.convertToObject(strings);
} catch (ValidationException e) {
// show "enter numeric build id/number" hint
} Prevention
- Always use the build picker UI instead of free text.
- Strip decoration like '#' from build numbers before submitting.
- Validate default values in job specs resolve to numbers.
When it happens
Trigger: convertToObject receives a non-numeric string where a build id/number is expected (e.g. user typed text into the choice field, or a parameter value referencing a build was hand-edited).
Common situations: Typing a build number with non-digit characters (#12, build-12); supplying a branch/commit string instead of a build number; default value in job spec referencing a build that no longer resolves to a number.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Invalid issue id/number
- Invalid commit id
- 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/12a7887ce1d01c3a.
Report an issue: GitHub.