{"record":{"id":"206c6add7f4fde37","repo":"theonedev/onedev","slug":"unable-to-find-pull-request-value","errorCode":null,"errorMessage":"Unable to find pull request: ${value}","messagePattern":"Unable to find pull request: (.+?)","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/QueryUtils.java","lineNumber":161,"sourceCode":"\t}\n\t\n\tpublic static Issue getIssue(@Nullable Project project, String value) {\n\t\tvar reference = IssueReference.of(value, project);\n\t\tvar issueService = OneDev.getInstance(IssueService.class);\n\t\tvar issue = issueService.find(reference.getProject(), reference.getNumber());\n\t\tif (issue != null)\n\t\t\treturn issue.resolveMovedTo();\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find issue: \" + value);\n\t}\n\t\n\tpublic static PullRequest getPullRequest(@Nullable Project project, String value) {\n\t\tvar reference = PullRequestReference.of(value, project);\n\t\tvar pullRequest = OneDev.getInstance(PullRequestService.class).find(reference.getProject(), reference.getNumber());\n\t\tif (pullRequest != null)\n\t\t\treturn pullRequest;\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find pull request: \" + value);\n\t}\n\t\n\tpublic static Build getBuild(@Nullable Project project, String value) {\n\t\tvar reference = BuildReference.of(value, project);\n\t\tvar build = OneDev.getInstance(BuildService.class).find(reference.getProject(), reference.getNumber());\n\t\tif (build != null)\n\t\t\treturn build;\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find build: \" + value);\n\t}\n\n\tpublic static Long getNumber(String value) {\n\t\tif (value.startsWith(\"#\"))\n\t\t\tvalue = value.substring(1);\n\t\ttry {\n\t\t\treturn Long.parseLong(value);\n\t\t} catch (NumberFormatException e) {\n\t\t\tthrow new NotAcceptableException(\"Invalid number: \" + value);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/QueryUtils.java#L143-L179","documentation":"QueryUtils.getPullRequest resolves a pull request reference (e.g. '#12' or 'project#12') via PullRequestService.find. When no pull request with that number exists in the referenced project, a NotFoundException 'Unable to find pull request' is thrown.","triggerScenarios":"Calling QueryUtils.getPullRequest with a PR number absent from the target project; missing project prefix when project is null; number refers to an issue or build rather than a pull request.","commonSituations":"Saved queries with PR numbers that were later deleted; confusing issue numbers with PR numbers (both use '#N'); PRs in projects the caller cannot access; typos in the number.","solutions":["Verify the pull request number exists in the specified project via the OneDev UI","Prefix the reference with the project path (e.g. 'group/project#12') or pass the correct default Project","Confirm the number is a pull request, not an issue or build number","Update saved queries if the PR was deleted or the project renamed"],"exampleFix":"// before\nPullRequest pr = QueryUtils.getPullRequest(null, \"#12\");\n// after\nPullRequest pr = QueryUtils.getPullRequest(project, \"group/my-project#12\");","handlingStrategy":"try-catch","validationCode":"if (!value.matches(\"(#\\\\d+|[^#]+#\\\\d+)\"))\n    throw new UserException(\"Pull request reference must look like '#12' or 'project#12'\");","typeGuard":"boolean isPullRequestReference(String s) {\n    return s != null && s.matches(\"(#\\\\d+|[^#]+#\\\\d+)\");\n}","tryCatchPattern":"try {\n    PullRequest pr = QueryUtils.getPullRequest(project, value);\n} catch (NotFoundException e) {\n    logger.warn(\"Pull request not found: {}\", value);\n}","preventionTips":["Scope PR references with the project path in cross-project contexts","Confirm the number is a pull request number via the UI","Refresh saved queries after PRs are deleted"],"tags":["pull-request","lookup","not-found","onedev"],"backgroundTag":"entity-not-found","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}