theonedev/onedev · error · NotAcceptableException
Pull request not found by id: ${pullRequestId}
Error message
Pull request not found by id: ${pullRequestId} What it means
OneDev throws this 406 NotAcceptableException when the optional pullRequestId in the workspace creation request does not match any existing pull request. pullRequestService.get(id) returns null for unknown ids.
Source
Thrown at server-core/src/main/java/io/onedev/server/rest/resource/WorkspaceResource.java:133
ObjectId commitId = ObjectId.fromString(data.getCommitHash());
var commit = project.getRevCommit(commitId, false);
if (commit == null)
throw new NotAcceptableException("Commit not found: " + data.getCommitHash());
Issue issue = null;
if (data.getIssueId() != null) {
issue = issueService.get(data.getIssueId());
if (issue == null)
throw new NotAcceptableException("Issue not found by id: " + data.getIssueId());
if (!issue.getProject().equals(project))
throw new NotAcceptableException("Issue does not belong to specified project");
}
PullRequest request = null;
if (data.getPullRequestId() != null) {
request = pullRequestService.get(data.getPullRequestId());
if (request == null)
throw new NotAcceptableException("Pull request not found by id: " + data.getPullRequestId());
if (!request.getProject().equals(project))
throw new NotAcceptableException("Pull request does not belong to specified project");
}
Workspace workspace = workspaceService.create(user, project, issue, request, commitId,
data.getBranch(), data.getSpecName(), false);
return workspace.getId();
}
@Api(order=400, description="Reprovision inactive workspace")
@Path("/{workspaceId}/reprovision")
@POST
public Response reprovisionWorkspace(@PathParam("workspaceId") Long workspaceId) {
Workspace workspace = workspaceService.load(workspaceId);
if (!SecurityUtils.canModifyOrDelete(workspace))
throw new UnauthorizedException();
if (workspace.getStatus() != Status.INACTIVE)
throw new NotAcceptableException("Only inactive workspaces can be reprovisioned");View on GitHub (pinned to d44925c47c)
Solutions
- Confirm the pull request id exists by fetching it via the pull request REST resource or the OneDev UI URL /<project>/pulls/<id>.
- Omit pullRequestId from the request if linking a PR is not required.
- Update automations to resolve the PR id from the PR number dynamically.
Example fix
// before data.setPullRequestId(Long.valueOf(prNumberText)); // UI number, not id // after PullRequest pr = pullRequestService.find(project, prNumber); if (pr != null) data.setPullRequestId(pr.getId());
Defensive patterns
Strategy: validation
Validate before calling
if (data.getPullRequestId() != null && pullRequestService.get(data.getPullRequestId()) == null)
throw new IllegalArgumentException("Pull request " + data.getPullRequestId() + " does not exist"); Type guard
PullRequest findPullRequest(Long id) {
return id == null ? null : pullRequestService.get(id);
} Try / catch
try {
workspaceId = createWorkspace(data);
} catch (NotAcceptableException e) {
if (e.getMessage().startsWith("Pull request not found")) data.setPullRequestId(null);
else throw e;
} Prevention
- Look up PR ids via the pull request REST/Java API, never from displayed numbers
- Purge stale PR references from scripts after PR deletion
- Null-check optional PR links before sending the request
When it happens
Trigger: POSTing to the workspace REST resource with data.pullRequestId set to an id of a deleted pull request, a typo'd id, or an id from a different OneDev instance.
Common situations: Scripts referencing PR ids after the PR was deleted; confusing a PR number displayed in the UI with the internal entity id; stale configuration in external CI tooling.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Commit not found: ${commitHash}
- Issue not found by id: ${issueId}
- Pull request does not belong to specified project
- Reviewer not found:
- Assignee not found:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/bea932d188d4e762.
Report an issue: GitHub.