gitbutlerapp/gitbutler · error · anyhow::Error
GitHub GraphQL repository not found for {owner}/{repo}
Error message
GitHub GraphQL repository not found for {owner}/{repo} What it means
A GraphQL query that looks up {owner}/{repo} (used when resolving a pull request node id) received a null `repository` field. GitHub answers this way when no repository with that name is visible to the authenticated account.
Source
Thrown at crates/but-github/src/client.rs:1227
#[derive(Deserialize)]
struct GraphQlPullRequest {
id: String,
}
let data: QueryData = self
.graphql_query(
GQL_GET_PR_NODE_ID,
&Variables {
owner,
repo,
number: pr_number,
},
)
.await?;
let Some(repository) = data.repository else {
bail!("GitHub GraphQL repository not found for {owner}/{repo}");
};
let Some(pull_request) = repository.pull_request else {
bail!("GitHub GraphQL pull request #{pr_number} not found for {owner}/{repo}",);
};
if pull_request.id.is_empty() {
bail!(
"GitHub GraphQL pull request #{pr_number} in {owner}/{repo} returned an empty node id",
);
}
Ok(PullRequestNodeId::from_string(pull_request.id))
}
async fn graphql_query<T, V>(&self, query: &str, variables: &V) -> Result<T>
where
T: for<'de> Deserialize<'de>,View on GitHub (pinned to caf1f223d3)
Solutions
- Open https://github.com/{owner}/{repo} in a browser as the same account to confirm the repo exists and is visible
- Re-authenticate with `but config forge auth`
- Check the forge/remote configuration for the intended owner, repo, and base URL
- For SAML-protected orgs, authorize the token for that organization
Defensive patterns
Strategy: validation
Validate before calling
let resp = reqwest::Client::new()
.get(format!("https://api.github.com/repos/{owner}/{repo}"))
.bearer_auth(token)
.send().await?;
match resp.status().as_u16() {
200 => {}
404 => anyhow::bail!("repo {owner}/{repo} not visible to this token - re-auth or check name"),
s => anyhow::bail!("repo lookup failed with HTTP {s}"),
} Try / catch
match client.get_pull_request_node_id(owner, repo, n).await {
Err(e) if e.to_string().contains("repository not found") => prompt_reauth_or_fix_remote(),
other => other?,
} Prevention
- Derive owner/repo from the actual git remote instead of hand-typed config
- Re-authenticate after org/permission changes
- Pre-check repo visibility with a cheap REST call in setup steps
When it happens
Trigger: Wrong owner/repo spelling or case in the remote; the repo is private and the token has no access; an expired or invalid token makes every repo invisible; a GitHub App that is not installed on the repo; a base_url pointing at the wrong GitHub host.
Common situations: Renamed or transferred repositories; org repos behind SAML the token never authorized; CI environments with no stored credentials; typos in URL-derived owner/repo pairs.
Related errors
- GitHub GraphQL pull request #{pr_number} not found for {owne
- GitHub GraphQL returned errors: {messages}
- GitHub GraphQL enablePullRequestAutoMerge returned an empty
- GitHub GraphQL disablePullRequestAutoMerge returned an empty
- GitHub GraphQL pull request #{pr_number} in {owner}/{repo} r
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/85ea474d82adae58.
Report an issue: GitHub.