theonedev/onedev · error · ValidationException
Invalid pull request id/number
Error message
Invalid pull request id/number
What it means
PullRequestChoiceInput.convertToObject parses a single user-supplied string into a Long pull request id/number. If the string cannot be parsed as a Long, a ValidationException with 'Invalid pull request id/number' is thrown. This input type accepts only one value and only numeric pull request ids/numbers.
Source
Thrown at server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/PullRequestChoiceInput.java:34
inputSpec.appendField(buffer, index, "Long");
inputSpec.appendCommonAnnotations(buffer, index);
if (!inputSpec.isAllowEmpty())
buffer.append(" @NotNull\n");
buffer.append(" @PullRequestChoice(useNumber=true)\n");
inputSpec.appendMethods(buffer, index, "Long", null, null);
return buffer.toString();
}
public static Object convertToObject(List<String> strings) {
if (strings.size() == 0) {
return null;
} else if (strings.size() == 1) {
String value = strings.iterator().next();
try {
return Long.valueOf(value);
} catch (NumberFormatException e) {
throw new ValidationException("Invalid pull request id/number");
}
} else {
throw new ValidationException("Not eligible for multi-value");
}
}
public static List<String> convertToStrings(Object value) {
if (value instanceof Long)
return Lists.newArrayList(value.toString());
else
return new ArrayList<>();
}
}
View on GitHub (pinned to d44925c47c)
Solutions
- Pass only the bare numeric pull request id or number (e.g. '12', not '#12' or the PR URL).
- Strip non-numeric prefixes/suffixes before calling convertToObject, or trim whitespace.
- Use the UI 'Pull Request' input selector rather than hand-editing the spec value.
- Validate the value with a regex ^\d+$ before invoking convertToObject.
Example fix
// before String pr = "https://onedev.example.com/proj/pulls/12"; Object value = PullRequestChoiceInput.convertToObject(Lists.newArrayList(pr)); // after String pr = "12"; // bare number extracted from the URL Object value = PullRequestChoiceInput.convertToObject(Lists.newArrayList(pr));
Defensive patterns
Strategy: validation
Validate before calling
boolean validPrValue(String s) {
return s != null && s.trim().matches("\\d+");
}
// call convertToObject only if validPrValue(value) Type guard
boolean isNumeric(String s) {
return s != null && s.matches("\\d+");
} Try / catch
try {
Object pr = PullRequestChoiceInput.convertToObject(Lists.newArrayList(value));
} catch (ValidationException e) {
// report/fix: value must be a bare numeric pull request id/number
} Prevention
- Always pass bare numeric PR ids/numbers, never URLs, titles, or '#12' forms.
- Trim and sanitize input strings before conversion.
- Use the UI pull-request picker instead of hand-editing spec values.
When it happens
Trigger: Calling PullRequestChoiceInput.convertToObject(List<String>) with a single-element list whose value is not parseable by Long.valueOf, e.g. a branch name, a URL like 'https://host/project/pulls/12', or a value with whitespace/typos.
Common situations: Buildspec job or CI/CD job input bound to a pull request choice where the user hand-typed a PR title or URL instead of the number; a script passing the full PR reference (e.g. '#12' or 'pulls/12') instead of the bare number; stale spec files after OneDev version changes.
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 boolean value
- Circular template usages (
- Error validating step template parameters (%s)
- Step template not found (
- Circular dependencies (
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/473b980f22806c76.
Report an issue: GitHub.