gitbutlerapp/gitbutler · error · anyhow::Error
Preferred GitHub account '{account}' has not authenticated y
Error message
Preferred GitHub account '{account}' has not authenticated yet.\nRun 'but config forge auth' to authenticate, or choose another account. What it means
A preferred GitHub account was passed to resolve_account, but it is not among the known (stored) authenticated accounts, so it cannot be used. The default - the first known account - is only chosen when no preference is expressed.
Source
Thrown at crates/but-github/src/client.rs:1977
}
}
}
pub(crate) fn resolve_account(
preferred_account: Option<&crate::GithubAccountIdentifier>,
storage: &but_forge_storage::Controller,
) -> Result<crate::GithubAccountIdentifier, anyhow::Error> {
let known_accounts = crate::token::list_known_github_accounts(storage)?;
let Some(default_account) = known_accounts.first() else {
bail!(
"No authenticated GitHub users found.\nRun 'but config forge auth' to authenticate with GitHub."
);
};
let account = if let Some(account) = preferred_account {
if known_accounts.contains(account) {
account
} else {
bail!(
"Preferred GitHub account '{account}' has not authenticated yet.\nRun 'but config forge auth' to authenticate, or choose another account."
);
}
} else {
default_account
};
Ok(account.to_owned())
}
#[derive(Serialize)]
struct CheckRunsQuery<'a> {
filter: &'a str,
per_page: usize,
page: usize,
}
/// Render a failed response as `<status>: <body>` so GitHub's error message reaches the user.View on GitHub (pinned to caf1f223d3)
Solutions
- Authenticate that account: `but config forge auth`
- Or clear/change the preferred-account setting so the default known account is used
- Make sure the identifier matches exactly what was stored during authentication
Defensive patterns
Strategy: validation
Validate before calling
let known = crate::token::list_known_github_accounts(storage)?;
if let Some(preferred) = &preferred_account {
if !known.contains(preferred) {
anyhow::bail!("account {preferred} not authenticated - run `but config forge auth`");
}
} Type guard
fn account_is_known(account: &GithubAccountIdentifier, known: &[GithubAccountIdentifier]) -> bool {
known.contains(account)
} Try / catch
match do_forge_operation().await {
Err(e) if e.to_string().contains("has not authenticated yet") => {
clear_preferred_account_and_use_default()
}
other => other?,
} Prevention
- Validate the preferred-account setting against stored accounts at startup
- Use the exact identifier produced by authentication
- Re-authenticate after switching or renaming GitHub accounts
When it happens
Trigger: A config entry or CLI flag names an account that never authenticated on this machine; the account was removed via logout; the identifier's casing or format differs from what was stored; the signed-in user changed.
Common situations: Multi-account setups; configs synced to a machine where only another account authenticated; GitHub username changes.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Preferred Bitbucket account '{account}' has not authenticate
- GitHub GraphQL request failed: {}
- No authenticated GitHub users found.\nRun 'but config forge
- GitHub returned an error: {} ({})
- Preferred GitLab account '{account}' has not authenticated y
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/cc21d0aa0bd46cb9.
Report an issue: GitHub.