{"record":{"id":"fc9c481d7577b464","repo":"theonedev/onedev","slug":"pull-request-not-found","errorCode":null,"errorMessage":"Pull request not found: ","messagePattern":"Pull request not found: ","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/ai/TodResource.java","lineNumber":1313,"sourceCode":"\n        var info = new CreatePullRequestEssentialInfo();\n        info.currentProject = currentProject;\n        info.target = target;\n        info.source = source;\n        info.submitter = user;\n\n        return info;\n    }    \n\n    private PullRequest getPullRequest(Project currentProject, String referenceString) {\n        var requestReference = PullRequestReference.of(referenceString, currentProject);\n        var request = pullRequestService.find(requestReference.getProject(), requestReference.getNumber());\n        if (request != null) {\n            if (!SecurityUtils.canReadCode(request.getProject()))\n                throw new UnauthorizedException(\"No permission to access pull request: \" + referenceString);\n            return request;\n        } else {\n            throw new NotFoundException(\"Pull request not found: \" + referenceString);\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Path(\"/edit-pull-request\")\n    @POST\n    public Map<String, Object> editPullRequest(\n                @QueryParam(\"currentProject\") @NotNull String currentProjectPath,\n                @QueryParam(\"reference\") @NotNull String pullRequestReference, @NotNull Map<String, Serializable> data) {\n        var user = SecurityUtils.getUser();\n        if (user == null)\n            throw new UnauthenticatedException();\n\n        var currentProject = getProject(currentProjectPath);\n\n        var request = getPullRequest(currentProject, pullRequestReference);\n\n        if (!SecurityUtils.canModifyPullRequest(request))","sourceCodeStart":1295,"sourceCodeEnd":1331,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L1295-L1331","documentation":"getPullRequest looks up the pull request by number via pullRequestService.find() after parsing the reference with PullRequestReference.of(). If no pull request with that number exists in the resolved project, it throws a JAX-RS NotFoundException (HTTP 404) naming the reference string.","triggerScenarios":"Calling a TOD pull-request endpoint with a 'reference' whose number does not exist in the current (or explicitly named) project, e.g. 'team-a/app#999' when only #1..#50 exist.","commonSituations":"Wrong project in reference so number resolves against the wrong PR sequence; PR deleted; stale reference from an old AI plan; bare '#123' interpreted in currentProject where it doesn't exist.","solutions":["Verify the pull request number exists in the resolved project (list PRs in the UI).","Use a fully-qualified reference ('project-path#number') to ensure the correct project is used.","Check the PR wasn't removed; pick the correct reference from the current plan."],"exampleFix":"// before\nvar ref = \"#999\"; // resolved in currentProject, doesn't exist\n// after\nvar ref = \"team-a/app#42\"; // existing PR, explicit project","handlingStrategy":"validation","validationCode":"var ref = PullRequestReference.of(referenceString, currentProject);\nif (pullRequestService.find(ref.getProject(), ref.getNumber()) == null)\n    throw new IllegalStateException(\"No pull request \" + referenceString + \" in \" + ref.getProject().getPath());","typeGuard":null,"tryCatchPattern":"try {\n    var pr = callTodEndpoint(reference);\n} catch (NotFoundException e) {\n    if (e.getMessage().startsWith(\"Pull request not found\")) {\n        // re-resolve the PR number via the project's PR list\n    } else throw e;\n}","preventionTips":["Refresh PR references from the live API rather than cached/stale plans.","Use fully-qualified 'project#number' references.","Remember PR numbers are per-project; never reuse a number across projects."],"tags":["pull-request","not-found","reference","onedev"],"backgroundTag":"record-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"}