{"record":{"id":"0594efebdd3d48d3","repo":"gitbutlerapp/gitbutler","slug":"failed-to-list-github-stacks","errorCode":null,"errorMessage":"Failed to list GitHub stacks: {}","messagePattern":"Failed to list GitHub stacks: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-github/src/stacks.rs","lineNumber":292,"sourceCode":"impl GitHubClient {\n    /// `Ok(None)` means the repository does not expose the native stacks endpoint.\n    async fn stacks_for_pull_request(\n        &self,\n        owner: &str,\n        repo: &str,\n        review_number: i64,\n    ) -> Result<Option<Vec<Stack>>> {\n        let response = self\n            .client\n            .get(format!(\"{}/repos/{owner}/{repo}/stacks\", self.base_url))\n            .query(&[(\"pull_request\", review_number)])\n            .send()\n            .await?;\n        if response.status() == reqwest::StatusCode::NOT_FOUND {\n            return Ok(None);\n        }\n        if !response.status().is_success() {\n            bail!(\n                \"Failed to list GitHub stacks: {}\",\n                response_error(response).await\n            );\n        }\n        Ok(Some(response.json().await?))\n    }\n\n    async fn create_stack(&self, owner: &str, repo: &str, desired: &[i64]) -> Result<()> {\n        let response = self\n            .client\n            .post(format!(\"{}/repos/{owner}/{repo}/stacks\", self.base_url))\n            .json(&StackMembersBody {\n                pull_requests: desired,\n            })\n            .send()\n            .await?;\n        if !response.status().is_success() {\n            bail!(","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-github/src/stacks.rs#L274-L310","documentation":"The GitHub REST call used by `stacks_for_pull_request` (via `existing_stacks`) returned a non-success, non-404 status. The client includes GitHub's response body (rendered by `response_error`) as the error detail, so the underlying cause is in the `{}` text.","triggerScenarios":"Calling existing_stacks/stacks_for_pull_request when the stack API endpoint responds 4xx/5xx — e.g. 401/403 for bad token or missing access to the repo, 404 only handled separately (returns Ok(None)), 422 for a bad owner/repo/PR, 5xx for GitHub-side issues.","commonSituations":"Token expired or lacking `repo` scope; wrong base_url (GitHub Enterprise misconfiguration) pointing at a non-GitHub server; typo'd owner/repo; GitHub incident returning 5xx.","solutions":["Read the status/body embedded in the message — it names the precise cause.","If 401/403, refresh the GitHub token and ensure it has `repo` scope and access to the repository.","If 404 keeps appearing unexpectedly, verify owner/repo spelling and that the correct base_url is configured (github.com vs GHES).","If 5xx, check the GitHub status page and retry with backoff."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate configuration and access before listing stacks\nanyhow::ensure!(!token.is_empty(), \"GitHub token missing\");\nanyhow::ensure!(owner_repo_matches(\"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$\"), \"bad owner/repo\");","typeGuard":null,"tryCatchPattern":"match stacks.existing_stacks(owner, repo, pr).await {\n    Ok(Some(stacks)) => use(stacks),\n    Ok(None) => handle_no_stack(), // 404 path\n    Err(e) if e.to_string().contains(\"401\") || e.to_string().contains(\"403\") => refresh_credentials(),\n    Err(e) => retry_or_surface(e),\n}","preventionTips":["Check token scopes and repo access before API-heavy operations.","Verify base_url matches your host (github.com vs GHES).","Treat 404 as 'no stacks' (the API already does) and handle Ok(None).","Retry 5xx with exponential backoff."],"tags":["github","api","http","network"],"backgroundTag":"http-error-response","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"}