gitbutlerapp/gitbutler · error
GitHub GraphQL pull request
Error message
GitHub GraphQL pull request {owner}/{repo}#{pr_number} not found What it means
The GraphQL get_pull_request query returns data.repository.pull_request as null when the repository or PR cannot be resolved (GitHub GraphQL returns errors with null data fields instead of HTTP errors). The client bails with this message to signal the PR was not found.
Solutions
- Verify the PR exists via REST: GET /repos/{owner}/{repo}/pulls/{n}
- Check the token can read the repo (GraphQL returns null instead of 404 for unauthorized repos)
- Confirm owner/repo strings match the GraphQL node names exactly (case-sensitive owner, repo slug)
Example fix
// before
let pr = client.get_pull_request("acme", "Repo", 12).await?; // wrong slug case
// after
let pr = client.get_pull_request("acme", "repo", 12).await?; Defensive patterns
Strategy: try-catch
Validate before calling
let resp = reqwest::Client::new()
.get(&format!("https://api.github.com/repos/{owner}/{repo}/pulls/{n}"))
.header("Authorization", format!("Bearer {token}"))
.send().await?;
if resp.status() == reqwest::StatusCode::NOT_FOUND {
return Err("PR does not exist or is inaccessible".into());
} Try / catch
match client.get_pull_request(owner, repo, n).await {
Ok(pr) => pr,
Err(e) if e.to_string().contains("not found") => {
eprintln!("PR #{n} unavailable; skipping");
return Ok(None);
}
Err(e) => return Err(e),
} Prevention
- Remember GraphQL returns null (not 404) for inaccessible PRs
- Verify repo visibility vs token scopes when PRs 'vanish'
- Check owner/repo node names exactly match GitHub slugs
When it happens
Trigger: Calling get_pull_request for a PR number that doesn't exist, in a repo the token can't see, or on a renamed/deleted repository — GraphQL resolves repository/pull_request to null.
Common situations: PR number from another repo or org; private repo with a token lacking access (GraphQL silently nulls); PR deleted between listing and fetch; typo in owner/repo node names.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- GitHub GraphQL convertPullRequestToDraft returned an empty…
- GitHub GraphQL disablePullRequestAutoMerge returned an…
- GitHub GraphQL enablePullRequestAutoMerge returned an empty…
- GitHub GraphQL markPullRequestReadyForReview returned an…
- Could not update all PR targets before native stack…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/0684e0f6b18968b4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-github/src/client.rs:520
struct Repository {
pull_request: Option<GraphQlPullRequest>,
}
let data: Data = self
.graphql_query(
GQL_GET_PR,
&Variables {
owner,
repo,
number: pr_number,
},
)
.await?;
let Some(pr) = data
.repository
.and_then(|repository| repository.pull_request)
else {
bail!("GitHub GraphQL pull request {owner}/{repo}#{pr_number} not found");
};
Ok(pr.into())
}
/// List the top-level conversation (issue) comments on a pull request,
/// oldest first. Paginated; review-thread (diff) comments are not included.
pub async fn list_pull_request_comments(
&self,
owner: &str,
repo: &str,
pr_number: i64,
) -> Result<Vec<PullRequestComment>> {
let url = format!(
"{}/repos/{}/{}/issues/{}/comments",
self.base_url, owner, repo, pr_number
);
Ok(selfView on GitHub (pinned to 58e5313667)