gitbutlerapp/gitbutler · error · anyhow::Error

No authenticated GitLab users found.\nRun 'but config forge

Error message

No authenticated GitLab users found.\nRun 'but config forge auth' to authenticate with GitLab.

What it means

Thrown by resolve_account (crates/but-gitlab/src/client.rs:1079) when but-forge storage contains zero authenticated GitLab accounts. resolve_account picks the default account for any GitLab operation, so this aborts before any API call is made. The fix is embedded in the message itself: authenticate via `but config forge auth`. This is a local-state error, not a network one — the token store simply has no GitLab entries.

Source

Thrown at crates/but-gitlab/src/client.rs:1079

}

fn source_project_differs_from_target(
    source_project_id: Option<i64>,
    target_project_id: Option<i64>,
    project_id: i64,
) -> bool {
    let source_project_id = source_project_id.unwrap_or(project_id);
    let target_project_id = target_project_id.unwrap_or(project_id);
    source_project_id != target_project_id
}

pub(crate) fn resolve_account(
    preferred_account: Option<&crate::GitlabAccountIdentifier>,
    storage: &but_forge_storage::Controller,
) -> Result<crate::GitlabAccountIdentifier, anyhow::Error> {
    let known_accounts = crate::token::list_known_gitlab_accounts(storage)?;
    let Some(default_account) = known_accounts.first() else {
        bail!(
            "No authenticated GitLab users found.\nRun 'but config forge auth' to authenticate with GitLab."
        );
    };
    let account = if let Some(account) = preferred_account {
        if known_accounts.contains(account) {
            account
        } else {
            bail!(
                "Preferred GitLab account '{account}' has not authenticated yet.\nRun 'but config forge auth' to authenticate, or choose another account."
            );
        }
    } else {
        default_account
    };

    Ok(account.to_owned())
}

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Run `but config forge auth` and pick GitLab to open the OAuth flow
  2. Verify afterwards that the account was stored (re-run the failing command; the error disappears once one account exists)
  3. If running in CI/another user, authenticate under that same user — tokens are not shared across profiles
  4. If you expected an account to exist, check that storage points at the same data dir used during auth

Example fix

// before
let account = resolve_account(None, &storage)?; // hard error, command aborts

// after
let account = match resolve_account(None, &storage) {
    Ok(account) => account,
    Err(err) if err.to_string().contains("No authenticated GitLab users") => {
        eprintln!("GitLab is not connected. Run `but config forge auth` first.");
        std::process::exit(2); // actionable exit instead of a stack-y error
    }
    Err(err) => return Err(err),
};
Defensive patterns

Strategy: validation

Validate before calling

// Check for any stored GitLab account before invoking account-dependent APIs
let known = but_gitlab::token::list_known_gitlab_accounts(&storage)?; // same store resolve_account reads
if known.is_empty() {
    eprintln!("GitLab is not connected. Run `but config forge auth` first.");
    std::process::exit(2);
}

Try / catch

let account = match resolve_account(None, &storage) {
    Ok(a) => a,
    Err(err) if err.to_string().contains("No authenticated GitLab users") => {
        anyhow::bail!("actionable: run `but config forge auth` to connect GitLab")
    }
    Err(err) => return Err(err),
};

Prevention

When it happens

Trigger: Any GitLab-backed operation on a fresh machine/profile where `but config forge auth` was never run for GitLab; the forge storage/database was reset or cleared; user authenticated only with GitHub and then called a GitLab-specific command.

Common situations: First run after install; user wiped GitButler app data; new workspace but tokens stored per-user were never created; scripts running under a different HOME/user than the one that authenticated.

Understand the failure class

Related errors


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