{"record":{"id":"90b878f7062708ea","repo":"gitbutlerapp/gitbutler","slug":"github-graphql-pull-request-pr-number-not-found","errorCode":null,"errorMessage":"GitHub GraphQL pull request #{pr_number} not found for {owner}/{repo}","messagePattern":"GitHub GraphQL pull request #(.+?) not found for (.+?)/(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-github/src/client.rs","lineNumber":1779,"sourceCode":"        }\n\n        let data: QueryData = self\n            .graphql_query(\n                GQL_GET_PR_NODE_ID,\n                &Variables {\n                    owner,\n                    repo,\n                    number: pr_number,\n                },\n            )\n            .await?;\n\n        let Some(repository) = data.repository else {\n            bail!(\"GitHub GraphQL repository not found for {owner}/{repo}\");\n        };\n\n        let Some(pull_request) = repository.pull_request else {\n            bail!(\"GitHub GraphQL pull request #{pr_number} not found for {owner}/{repo}\",);\n        };\n\n        if pull_request.id.is_empty() {\n            bail!(\n                \"GitHub GraphQL pull request #{pr_number} in {owner}/{repo} returned an empty node id\",\n            );\n        }\n\n        Ok(PullRequestNodeId::from_string(pull_request.id))\n    }\n\n    async fn graphql_query<T, V>(&self, query: &str, variables: &V) -> Result<T>\n    where\n        T: for<'de> Deserialize<'de>,\n        V: Serialize,\n    {\n        #[derive(Serialize)]\n        struct GraphQlRequest<'a, V> {","sourceCodeStart":1761,"sourceCodeEnd":1797,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-github/src/client.rs#L1761-L1797","documentation":"The repository resolved in GraphQL but repository.pull_request(number: pr_number) was null — no pull request with that number exists (or is visible to the token) in that repository. Note GitHub shares the issue/PR number space, so a number can exist as an issue without being a PR.","triggerScenarios":"Calling get_pull_request_node_id (directly or via set_pull_request_draft_state / auto-merge APIs) with a PR number that is actually an issue number, a closed-and-doesn't-exist number, or a number from a different repository.","commonSituations":"Copying a number from an issue tracker ticket that doesn't match the PR number; referring to a PR in a fork rather than the upstream repo; PR number from stale config after branch cleanup; token can't see PRs from a private repo.","solutions":["Verify the number is a pull request, not an issue (GitHub numbers both in one sequence): check github.com/{owner}/{repo}/pull/{n}","Confirm the PR belongs to the same owner/repo passed to the API","Re-fetch the current PR number — the PR may have been closed and the automation config is stale","Ensure the token can see the repository's PRs (private repo access/SSO)"],"exampleFix":"// before\nlet pr_number = 42; // actually an issue number\n// after\nlet pr_number = 57; // correct PR number verified via gh pr list","handlingStrategy":"validation","validationCode":"// verify the number is really a PR in this repo before mutating\nlet pr = client.get_pull_request(owner, repo, pr_number).await?; // errors early if it's an issue or missing","typeGuard":null,"tryCatchPattern":"match client.get_pull_request_node_id(owner, repo, pr_number).await {\n    Err(e) if e.to_string().contains(\"not found\") => {\n        eprintln!(\"#{pr_number} is not a pull request in {owner}/{repo} — check issue vs PR number\");\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["Remember issues and PRs share one number sequence — verify /pull/{n} resolves","Pass the upstream repo's PR number, not the fork's","Refetch current PR numbers instead of hardcoding them in configs","Confirm token visibility for private repositories"],"tags":["github","graphql","pull-request-not-found","lookup"],"backgroundTag":"record-not-found","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}