{"record":{"id":"6f818b9e43670b40","repo":"gitbutlerapp/gitbutler","slug":"no-authenticated-gitlab-users-found-nrun-but-con","errorCode":null,"errorMessage":"No authenticated GitLab users found.\\nRun 'but config forge auth' to authenticate with GitLab.","messagePattern":"No authenticated GitLab users found\\.\\\\nRun 'but config forge auth' to authenticate with GitLab\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-gitlab/src/client.rs","lineNumber":1079,"sourceCode":"}\n\nfn source_project_differs_from_target(\n    source_project_id: Option<i64>,\n    target_project_id: Option<i64>,\n    project_id: i64,\n) -> bool {\n    let source_project_id = source_project_id.unwrap_or(project_id);\n    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","sourceCodeStart":1061,"sourceCodeEnd":1097,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-gitlab/src/client.rs#L1061-L1097","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `but config forge auth` and pick GitLab to open the OAuth flow","Verify afterwards that the account was stored (re-run the failing command; the error disappears once one account exists)","If running in CI/another user, authenticate under that same user — tokens are not shared across profiles","If you expected an account to exist, check that storage points at the same data dir used during auth"],"exampleFix":"// before\nlet account = resolve_account(None, &storage)?; // hard error, command aborts\n\n// after\nlet account = match resolve_account(None, &storage) {\n    Ok(account) => account,\n    Err(err) if err.to_string().contains(\"No authenticated GitLab users\") => {\n        eprintln!(\"GitLab is not connected. Run `but config forge auth` first.\");\n        std::process::exit(2); // actionable exit instead of a stack-y error\n    }\n    Err(err) => return Err(err),\n};","handlingStrategy":"validation","validationCode":"// Check for any stored GitLab account before invoking account-dependent APIs\nlet known = but_gitlab::token::list_known_gitlab_accounts(&storage)?; // same store resolve_account reads\nif known.is_empty() {\n    eprintln!(\"GitLab is not connected. Run `but config forge auth` first.\");\n    std::process::exit(2);\n}","typeGuard":null,"tryCatchPattern":"let account = match resolve_account(None, &storage) {\n    Ok(a) => a,\n    Err(err) if err.to_string().contains(\"No authenticated GitLab users\") => {\n        anyhow::bail!(\"actionable: run `but config forge auth` to connect GitLab\")\n    }\n    Err(err) => return Err(err),\n};","preventionTips":["Gate GitLab features behind a connected-account check at app/command startup","Run `but config forge auth` as part of environment setup in CI and fresh installs"],"tags":["gitlab","authentication","accounts","cli","rust"],"backgroundTag":"missing-credentials","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-09-01T03:17:15.561Z"}