{"record":{"id":"24a92ad5b91de5e5","repo":"gitbutlerapp/gitbutler","slug":"known-account-is-not-correctly-authenticated-run","errorCode":null,"errorMessage":"Known account is not correctly authenticated.\nRun '{}' to authenticate with {}.","messagePattern":"Known account is not correctly authenticated\\.\nRun '(.+?)' to authenticate with (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/forge/review.rs","lineNumber":411,"sourceCode":"            \"Unable to determine the forge for this project. Is target branch associated with a supported forge?\"\n        )\n    })?;\n\n    let account_validity =\n        but_forge::check_forge_account_is_valid(preferred_forge_user, &forge_repo_info, &storage)\n            .await?;\n\n    let forge_display_name = match forge_repo_info.forge {\n        but_forge::ForgeName::Azure => {\n            anyhow::bail!(\"Azure is unsupported at the minute. Sorry 😞.\");\n        }\n        but_forge::ForgeName::GitHub => \"GitHub\",\n        but_forge::ForgeName::GitLab => \"GitLab\",\n        but_forge::ForgeName::Bitbucket => \"Bitbucket\",\n    };\n\n    match account_validity {\n        but_forge::ForgeAccountValidity::Invalid => Err(anyhow::anyhow!(\n            \"Known account is not correctly authenticated.\\nRun '{}' to authenticate with {}.\",\n            \"but config forge auth\",\n            forge_display_name\n        )),\n        but_forge::ForgeAccountValidity::NoCredentials => Err(anyhow::anyhow!(\n            \"No authenticated forge users found.\\nRun '{}' to authenticate with {}.\",\n            \"but config forge auth\",\n            forge_display_name\n        )),\n        but_forge::ForgeAccountValidity::Valid => {\n            // All good, continue\n            Ok(())\n        }\n    }\n}\n\n/// Get list of branch names that don't have PRs yet.\nfn get_branches_without_prs(","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/forge/review.rs#L393-L429","documentation":"Thrown by the `but forge review` flow after it resolves the repo's forge (GitHub/GitLab/Bitbucket) and checks the stored account. `ForgeAccountValidity::Invalid` means a forge user is on record for the remote but its credentials no longer pass validation, so the command refuses to continue instead of making unauthenticated forge API calls. The message embeds the exact remediation: run `but config forge auth`. (Azure hits a separate, earlier bail in the same match.)","triggerScenarios":"Running `but forge review` or its publish flow when the saved forge token is expired, revoked, or otherwise rejected; the account-validity lookup returns `Invalid` and the match arm builds this anyhow error with the forge display name.","commonSituations":"Expired GitHub PAT or GitLab token after a rotation window; token revoked from the forge's settings page; org SSO/SAML access removed; credential store restored from an old machine; long-lived CI container with stale auth.","solutions":["Run `but config forge auth` and complete authentication for the forge named in the message","If auth keeps failing, verify in the forge's settings that the token still exists and has the required scopes","Check the repo's remote URL points at the forge/account you intended (fork vs upstream mismatch)","Re-run `but forge review` once validity reports Valid"],"exampleFix":"# before\nbut forge review\n# error: Known account is not correctly authenticated.\n# Run 'but config forge auth' to authenticate with GitHub.\n\n# after\nbut config forge auth\nbut forge review","handlingStrategy":"validation","validationCode":"# Refresh forge credentials before any review/publish automation\nbut config forge auth\n# then run the review flow; validity is checked inside it and fails fast with the fix named","typeGuard":"fn forge_account_usable(v: &but_forge::ForgeAccountValidity) -> bool {\n    matches!(v, but_forge::ForgeAccountValidity::Valid)\n}","tryCatchPattern":"// CLI-level: detect the auth failure and route to re-auth\nlet out = Command::new(\"but\").args([\"forge\", \"review\"]).output()?;\nif !out.status.success()\n    && String::from_utf8_lossy(&out.stderr).contains(\"not correctly authenticated\")\n{\n    eprintln!(\"run `but config forge auth`, then retry\");\n}","preventionTips":["Re-authenticate before starting long review or publish sessions","Rotate forge tokens on a schedule and re-run `but config forge auth` after every rotation","Keep one forge account per remote URL so validity checks hit the right user","In CI, run auth as an explicit setup step and fail fast on its exit code"],"tags":["forge","authentication","credentials","cli"],"backgroundTag":"stored-credentials-invalid","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}