{"record":{"id":"877b2fa2b607a999","repo":"gitbutlerapp/gitbutler","slug":"preferred-gitlab-account-account-has-not-authe","errorCode":null,"errorMessage":"Preferred GitLab account '{account}' has not authenticated yet.\\nRun 'but config forge auth' to authenticate, or choose another account.","messagePattern":"Preferred GitLab account '(.+?)' has not authenticated yet\\.\\\\nRun 'but config forge auth' to authenticate, or choose another account\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-gitlab/src/client.rs","lineNumber":1087,"sourceCode":"    let target_project_id = target_project_id.unwrap_or(project_id);\n    source_project_id != target_project_id\n}\n\npub(crate) fn resolve_account(\n    preferred_account: Option<&crate::GitlabAccountIdentifier>,\n    storage: &but_forge_storage::Controller,\n) -> Result<crate::GitlabAccountIdentifier, anyhow::Error> {\n    let known_accounts = crate::token::list_known_gitlab_accounts(storage)?;\n    let Some(default_account) = known_accounts.first() else {\n        bail!(\n            \"No authenticated GitLab users found.\\nRun 'but config forge auth' to authenticate with GitLab.\"\n        );\n    };\n    let account = if let Some(account) = preferred_account {\n        if known_accounts.contains(account) {\n            account\n        } else {\n            bail!(\n                \"Preferred GitLab account '{account}' has not authenticated yet.\\nRun 'but config forge auth' to authenticate, or choose another account.\"\n            );\n        }\n    } else {\n        default_account\n    };\n\n    Ok(account.to_owned())\n}\n\n#[cfg(test)]\nmod tests {\n    use super::{\n        GitLabMergeRequest, GitLabPipelineJob, GitLabPipelineRef, MAX_MERGE_REQUEST_REQUESTS,\n        MergeRequest, merge_request_page_is_safe, next_page_from_headers, normalize_pipeline_jobs,\n        repo_owner_from_path_with_namespace, update_draft_state_in_title,\n    };\n    use reqwest::header::{HeaderMap, HeaderValue};","sourceCodeStart":1069,"sourceCodeEnd":1105,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-gitlab/src/client.rs#L1069-L1105","documentation":"Thrown by resolve_account when a preferred GitLab account was explicitly requested but it is not among the accounts known to but-forge storage. The identifier is compared against the token store's account list; any mismatch — typo, different casing/format, or the account simply never completed auth on this machine — bails. Unlike the no-accounts error, valid accounts exist; the requested one just is not one of them.","triggerScenarios":"Calling a GitLab API with preferred_account = Some(&identifier) where identifier is a handle that never ran `but config forge auth` on this machine; the account's name/email changed on GitLab so the stored identifier differs from the configured one; configuration copied between machines that authenticated different accounts; casing or formatting mismatch in the stored preference.","commonSituations":"Multi-account users (work + personal) with a stale default in settings; dotfiles/config synced across machines where only one machine authenticated the second account; rename on GitLab.com breaking a stored identifier.","solutions":["Run `but config forge auth` and authenticate specifically as that account, then retry","List the authenticated accounts and use one of those identifiers instead (or pass None to take the default)","If the GitLab account name/email changed, re-auth to refresh the stored identifier and update the preference to match","Check for casing/whitespace differences between the preferred identifier and the stored one"],"exampleFix":"// before\nlet account = resolve_account(Some(&preferred), &storage)?; // unknown handle aborts\n\n// after: fall back to the default account with a warning\nlet account = match resolve_account(Some(&preferred), &storage) {\n    Ok(account) => account,\n    Err(err) if err.to_string().contains(\"has not authenticated yet\") => {\n        tracing::warn!(%preferred, \"account not authenticated; using default\");\n        resolve_account(None, &storage)?\n    }\n    Err(err) => return Err(err),\n};","handlingStrategy":"validation","validationCode":"// Validate the preferred account against the store before calling Git APIs\nlet known = but_gitlab::token::list_known_gitlab_accounts(&storage)?;\nlet account = match preferred_account.filter(|a| known.contains(a)) {\n    Some(a) => a.clone(),\n    None => known.first().cloned().context(\"no GitLab accounts authenticated\")?, // fall back to default\n};","typeGuard":null,"tryCatchPattern":"match resolve_account(Some(&preferred), &storage) {\n    Ok(account) => Ok(account),\n    Err(err) if err.to_string().contains(\"has not authenticated yet\") => {\n        tracing::warn!(%preferred, \"not authenticated; falling back to default account\");\n        resolve_account(None, &storage)\n    }\n    Err(err) => Err(err),\n}","preventionTips":["Persist the account identifier exactly as `but config forge auth` stored it (watch casing and email vs username)","After renaming a GitLab account, re-auth and update saved preferences"],"tags":["gitlab","authentication","accounts","multi-account","rust"],"backgroundTag":"account-not-authenticated","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-09-01T03:17:15.561Z"}