{"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/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/forge/review.rs#L393-L429","documentation":"This error is thrown by ensure_forge_authentication when a forge account known to GitButler (stored locally) fails a validity check against the forge (GitHub/GitLab/Bitbucket). It means the stored credentials exist but are stale, revoked, or otherwise rejected, so review/merge operations cannot proceed. The library throws it before any forge API call is made to fail fast with an actionable remediation command.","triggerScenarios":"Calling enable_auto_merge, set_draftiness, or create_review when ForgeAccountValidity::Invalid is returned for the known account — e.g. after a token was revoked server-side, expired, or the password/credential changed.","commonSituations":"Developers hit this after rotating a GitHub personal access token, when an organization revoked an OAuth grant, after a long-lived token expired, or when SSO/session policies invalidate stored GitButler credentials.","solutions":["Run `but config forge auth` to re-authenticate with the forge","Verify the token is still valid on the forge's developer settings page (GitHub: Settings > Applications; GitLab: Preferences > Access Tokens)","Check that the account has not been removed from the organization or had OAuth grants revoked","Retry the operation after re-authenticating"],"exampleFix":"// before\nbut forge review create ...\n// error: Known account is not correctly authenticated.\n// after\nbut config forge auth\nbut forge review create ...","handlingStrategy":"try-catch","validationCode":"// before invoking review/merge ops, check auth state via the CLI\nif !but config forge status --check; then\n  echo 'run: but config forge auth';\nfi","typeGuard":"function isAuthError(e: Error): boolean {\n  return /not correctly authenticated/i.test(e.message);\n}","tryCatchPattern":"try {\n  await runBut(['forge', 'review', 'create']);\n} catch (e) {\n  if (/not correctly authenticated/.test(e.message)) {\n    await runBut(['config', 'forge', 'auth']);\n    return retry();\n  }\n  throw e;\n}","preventionTips":["Re-run `but config forge auth` after rotating forge tokens","Monitor forge token expiry dates","Avoid revoking OAuth grants for GitButler without re-authenticating"],"tags":["forge","authentication","cli","github","gitlab"],"backgroundTag":"authentication-required","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"}