gitbutlerapp/gitbutler · error · anyhow::Error

No Bitbucket access token found for account

Error message

No Bitbucket access token found for account '{account_id}'.
Run 'but config forge auth' to re-authenticate.

What it means

BitbucketClient::from_storage resolved which account to use from stored forge configuration, but found no access token for that account in token storage. Without a token no API calls are possible, so the constructor fails and the message points at the re-authentication command ('but config forge auth').

Solutions

  1. Run `but config forge auth` and complete the Bitbucket flow to store a fresh token
  2. Confirm the account id named in the error is the account you expect (`but config forge` to list configured accounts)
  3. If auth succeeds but the error returns, check OS keychain/secret-service permissions for the but/GitButler app
Defensive patterns

Strategy: retry

Validate before calling

// Rust: check token availability before constructing the client
let account_id = resolve_account(preferred_account, storage)?;
if but_bitbucket::token::get_bb_access_token(&account_id, storage)?.is_none() {
    // prompt `but config forge auth` instead of calling BitbucketClient::from_storage
}

Try / catch

match BitbucketClient::from_storage(storage, preferred) {
    Err(err) if err.to_string().contains("No Bitbucket access token") => {
        // prompt re-auth (`but config forge auth`), then retry once
    }
    result => result,
}

Prevention

When it happens

Trigger: Constructing BitbucketClient::from_storage (directly or via any Bitbucket forge feature) when the resolved account's token entry is absent: the user never completed auth, the token was purged, or OS secret storage denied access.

Common situations: First use with no prior `but config forge auth`; app data or OS keychain reset/locked (macOS keychain, Windows credential manager, Linux secret service); migration or cleanup wiped stored tokens.

Understand the failure class

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/412027e62e72ebf7. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-bitbucket/src/client.rs:64

            .default_headers(headers)
            .timeout(BITBUCKET_REQUEST_TIMEOUT)
            .build()?;

        Ok(Self {
            client,
            base_url: BITBUCKET_API_BASE_URL.to_string(),
        })
    }

    pub fn from_storage(
        storage: &but_forge_storage::Controller,
        preferred_account: Option<&crate::BitbucketAccountIdentifier>,
    ) -> Result<Self> {
        let account_id = resolve_account(preferred_account, storage)?;
        if let Some(access_token) = crate::token::get_bb_access_token(&account_id, storage)? {
            account_id.client(&access_token)
        } else {
            Err(anyhow::anyhow!(
                "No Bitbucket access token found for account '{account_id}'.\nRun 'but config forge auth' to re-authenticate."
            ))
        }
    }

    pub async fn get_authenticated(&self) -> Result<AuthenticatedUser> {
        let url = format!("{}/user", self.base_url);
        let response = self.client.get(&url).send().await?;

        if !response.status().is_success() {
            return Err(HttpStatusError {
                status: response.status(),
            }
            .into());
        }

        let user: BitbucketApiUser = response.json().await?;
        Ok(AuthenticatedUser {

View on GitHub (pinned to caf1f223d3)