theonedev/onedev · error · NotAcceptableException
Invalid pull request number: {0}
Error message
Invalid pull request number: {0} What it means
PullRequestDetailPage parses the request number from URL parameters and throws NotAcceptableException when it is not a valid Long. Format validation happens before any service lookup, so this is purely an input-format error.
Source
Thrown at server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/PullRequestDetailPage.java:253
public PullRequestDetailPage(PageParameters params) {
super(params);
String requestNumberString = params.get(PARAM_REQUEST).toString();
if (StringUtils.isBlank(requestNumberString)) {
throw new RestartResponseException(ProjectPullRequestsPage.class,
ProjectPullRequestsPage.paramsOf(getProject(), null, 0));
}
requestModel = new LoadableDetachableModel<>() {
@Override
protected PullRequest load() {
Long requestNumber;
try {
requestNumber = Long.valueOf(requestNumberString);
} catch (NumberFormatException e) {
throw new NotAcceptableException(MessageFormat.format(_T("Invalid pull request number: {0}"), requestNumberString));
}
PullRequest request = pullRequestService.find(getProject(), requestNumber);
if (request == null) {
throw new EntityNotFoundException(MessageFormat.format(_T("Unable to find pull request #{0} in project {1}"), requestNumber, getProject().getPath()));
} else if (!request.getTargetProject().equals(getProject())) {
throw new RestartResponseException(getPageClass(), paramsOf(request));
} else {
return request;
}
}
};
if (!getPullRequest().isValid()) {
throw new RestartResponseException(InvalidPullRequestPage.class,
InvalidPullRequestPage.paramsOf(getPullRequest()));
}View on GitHub (pinned to d44925c47c)
Solutions
- Use only the bare numeric request number in the URL.
- Generate links via PullRequestDetailPage.paramsOf(request) instead of string concatenation.
- Strip non-numeric characters (like '#') from the number before building the URL.
Example fix
// before String url = "/~pulls/" + "#" + prNumber; // after String url = "/~pulls/" + request.getNumber();
Defensive patterns
Strategy: validation
Validate before calling
if (!requestNumberStr.matches("\\d+")) throw new IllegalArgumentException("PR number must be numeric: " + requestNumberStr);
Long number = Long.valueOf(requestNumberStr); Type guard
Long parseRequestNumber(String s) { try { return Long.valueOf(s); } catch (NumberFormatException e) { return null; } } Try / catch
try { open(PullRequestDetailPage.paramsOf(request)); } catch (NumberFormatException e) { log.error("Bad PR number format"); } Prevention
- Use PullRequestDetailPage.paramsOf(request) for link building.
- Strip decorations like '#' or 'PR-' before forming URLs.
- Never interpolate titles or keys into numeric URL segments.
When it happens
Trigger: Visiting a pull request detail URL with a non-numeric number segment, e.g. /~pulls/abc; link generation inserting a PR title/key instead of the numeric request number.
Common situations: Hand-edited URLs; truncated bookmarks; scripts that format PR references like '#12' or 'PR-12' into URLs where only '12' is valid.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Invalid issue number: {0}
- Invalid pack ID: {0}
- Invalid number: ${token}
- Resource class not found: ${className}
- Unable to find pull request #<n> in project <project>
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/14d93192ee4d7c1d.
Report an issue: GitHub.