{"record":{"id":"a80fdf77e83b2a9e","repo":"gitbutlerapp/gitbutler","slug":"preferred-bitbucket-account-account-has-not-au","errorCode":null,"errorMessage":"Preferred Bitbucket account '{account}' has not authenticated yet.\nRun 'but config forge auth' to authenticate, or choose another account.","messagePattern":"Preferred Bitbucket account '(.+?)' has not authenticated yet\\.\nRun 'but config forge auth' to authenticate, or choose another account\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-bitbucket/src/client.rs","lineNumber":634,"sourceCode":"        ))\n    }\n}\n\npub(crate) fn resolve_account(\n    preferred_account: Option<&crate::BitbucketAccountIdentifier>,\n    storage: &but_forge_storage::Controller,\n) -> Result<crate::BitbucketAccountIdentifier, anyhow::Error> {\n    let known_accounts = crate::token::list_known_bitbucket_accounts(storage)?;\n    let Some(default_account) = known_accounts.first() else {\n        bail!(\n            \"No authenticated Bitbucket users found.\\nRun 'but config forge auth' to authenticate with Bitbucket.\"\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 Bitbucket 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/// Escape a value for embedding inside a double-quoted Bitbucket query-language\n/// string, so a branch name with quotes/backslashes can't break or inject into\n/// the query.\nfn escape_bbql(value: &str) -> String {\n    value.replace('\\\\', \"\\\\\\\\\").replace('\"', \"\\\\\\\"\")\n}\n\n/// BBQL predicate matching pull requests in any state targeting `target_branch`.","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-bitbucket/src/client.rs#L616-L652","documentation":"resolve_account() bails when the caller explicitly passed a preferred_account (a BitbucketAccountIdentifier) that is not present in list_known_bitbucket_accounts(storage). The default account path is deliberately skipped — only a mismatched explicit selection fails. The message suggests either authenticating that account or choosing another one.","triggerScenarios":"Passing an account id/username that authenticated on a different machine or was logged out since; multi-account setups where the caller pins an account by stale config; case/format differences between the stored identifier and the requested one.","commonSituations":"Team configs pinning an account name after the member re-authenticated under a different username; copied dotfiles/config between machines; account removed via auth management but still referenced in repo-level forge settings.","solutions":["Run 'but config forge auth' and authenticate specifically as that account","Or drop the preferred-account override so resolve_account falls back to the default (first known) account","Verify the identifier matches exactly what token storage recorded (list_known_bitbucket_accounts)","Remove the stale account reference from the config that is injecting it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let known = but_bitbucket::token::list_known_bitbucket_accounts(storage)?;\nif let Some(preferred) = &requested {\n    anyhow::ensure!(known.contains(preferred),\n        \"account {preferred} not authenticated; known: {known:?}\");\n}","typeGuard":null,"tryCatchPattern":"// fall back to the default account when the pinned one is unknown\nmatch resolve_account(Some(&preferred), storage) {\n    Err(e) if e.to_string().contains(\"has not authenticated yet\") =>\n        resolve_account(None, storage)?, // or prompt re-auth\n    r => r?,\n}","preventionTips":["Validate pinned account ids against list_known_bitbucket_accounts on startup","After re-auth or logout events, drop cached account references","Offer an account picker fed by the known-accounts list instead of free-text input"],"tags":["bitbucket","authentication","multi-account","forge"],"backgroundTag":"unauthenticated-account-selected","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}