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

  1. Open https://github.com/{owner}/{repo} in a browser as the same account to confirm the repo exists and is visible
  2. Re-authenticate with `but config forge auth`
  3. Check the forge/remote configuration for the intended owner, repo, and base URL
  4. 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

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


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/85ea474d82adae58. Report an issue: GitHub.