gitbutlerapp/gitbutler · warning · anyhow::Error
Could not determine authentication method
Error message
Could not determine authentication method
What it means
GitLab authentication setup prompts for a method (Personal Access Token vs Self-Hosted GitLab) via prompt_select; the error is raised when that picker yields no selection. It means the chooser was cancelled/aborted before an entry was confirmed, so there is no AuthMethod to dispatch to gitlab_pat()/gitlab_self_hosted(). Purely a cancellation guard.
Source
Thrown at crates/but/src/command/config.rs:987
match method {
AuthMethod::Pat => "Personal Access Token (PAT)".to_string(),
AuthMethod::SelfHosted => "Self-Hosted GitLab".to_string(),
}
}
}
let mut input = out
.prepare_for_terminal_input()
.context("Human input required - run this in a terminal")?;
let auth_methods = nonempty::nonempty![
("Personal Access Token (PAT)", AuthMethod::Pat),
("Self-Hosted GitLab", AuthMethod::SelfHosted)
];
let selected_method = input
.prompt_select("Select an authentication method", &auth_methods)?
.cloned()
.ok_or_else(|| anyhow::anyhow!("Could not determine authentication method"))?;
match selected_method {
AuthMethod::Pat => gitlab_pat(input).await,
AuthMethod::SelfHosted => gitlab_self_hosted(input).await,
}
}
/// Authenticate with GitLab using a Personal Access Token (PAT)
async fn gitlab_pat(mut inout: InputOutputChannel<'_>) -> Result<()> {
use but_gitlab::AuthStatusResponse;
let input = inout
.prompt_secret("Please enter your GitLab Personal Access Token (PAT) and hit enter:")?
.context("No PAT provided. Aborting authentication.")?;
let AuthStatusResponse { username, .. } = but_api::gitlab::store_gitlab_pat(input)
.await
.map_err(|err| err.context("Authentication failed"))?;View on GitHub (pinned to caf1f223d3)
Solutions
- Create the GitLab PAT first (scopes: api/read_user as needed), then re-run and pick 'Personal Access Token (PAT)'.
- For self-managed GitLab, have the instance URL ready, re-run and pick 'Self-Hosted GitLab'.
- Confirm the pick with Enter; Esc/Ctrl-C is treated as 'no method' and errors here.
Defensive patterns
Strategy: try-catch
Try / catch
match gitlab_auth(out).await {
Err(e) if e.to_string().contains("Could not determine authentication method") => {
println!("GitLab auth cancelled."); Ok(())
}
other => other,
} Prevention
- Prepare the PAT (or self-hosted URL) before launching the flow.
- Confirm picker entries with Enter; Esc always aborts to this error.
When it happens
Trigger: Running GitLab auth flow and pressing Esc / killing the fuzzy picker before selecting 'Personal Access Token (PAT)' or 'Self-Hosted GitLab'.
Common situations: Backing out after realizing you don't have a PAT at hand; aborting to go read the required scopes first; flaky terminal over SSH.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Could not determine which forge provider to authenticate wit
- Could not determine which accounts to delete
- Could not determine selected AI provider
- Could not determine OpenAI credential source
- Could not determine Anthropic credential source
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/4cbd375015d1e95e.
Report an issue: GitHub.