gitbutlerapp/gitbutler · error

Could not determine which forge provider to authenticate…

Error message

Could not determine which forge provider to authenticate with

What it means

Raised in `forge_auth` (crates/but/src/command/config.rs:866) when the interactive prompt for selecting a forge provider returns no selectable option — the user provided no selection (e.g. EOF, non-interactive stdin, or empty option list), so no provider can be chosen.

Solutions

  1. Run the command in an interactive terminal so the provider prompt can be answered
  2. Select one of the listed providers when prompted instead of aborting
  3. Use a non-interactive configuration path (e.g. set forge credentials via config files or env) if no TTY is available
  4. Ensure the provider list is populated — check your build/features if the list is unexpectedly empty

Example fix

// before
echo | but config forge auth   # prompt gets EOF -> no selection
// after
but config forge auth   # run interactively and pick GitHub/GitLab
Defensive patterns

Strategy: try-catch

Validate before calling

use std::io::IsTerminal;
if !std::io::stdin().is_terminal() {
    return Err("forge auth requires an interactive terminal; configure credentials non-interactively instead");
}

Try / catch

match forge_auth(&mut out).await {
    Err(e) if e.to_string().contains("which forge provider") => eprintln!("run interactively and select a provider"),
    other => other,
}

Prevention

When it happens

Trigger: Running the forge auth configuration flow when `input.prompt_select(...)` returns `None`: non-interactive stdin (piped/closed), user aborting the prompt, or `auth_options` being empty.

Common situations: Scripting `but config forge auth` without a TTY; CI environments where prompts can't render; canceling the selection dialog.

Understand the failure class

Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/8f44ff218419e90a. Report an issue: GitHub.

Appendix: source

Thrown at crates/but/src/command/config.rs:866

    }

    let auth_options = nonempty::nonempty![
        ("GitHub", ForgeProvider::GitHub),
        ("GitLab", ForgeProvider::GitLab),
        ("Bitbucket", ForgeProvider::Bitbucket)
    ];
    let selected_option = {
        let mut input = out
            .prepare_for_terminal_input()
            .context("Human input required - run this in a terminal")?;
        input
            .prompt_select(
                "Select a forge provider to authenticate with",
                &auth_options,
            )?
            .cloned()
            .ok_or_else(|| {
                anyhow::anyhow!("Could not determine which forge provider to authenticate with")
            })?
    };

    match selected_option {
        ForgeProvider::GitHub => github_auth(out).await,
        ForgeProvider::GitLab => gitlab_auth(out).await,
        ForgeProvider::Bitbucket => bitbucket_auth(out).await,
    }
}

/// Authenticate with Bitbucket Cloud using an Atlassian API token.
async fn bitbucket_auth(out: &mut OutputChannel) -> Result<()> {
    use but_bitbucket::AuthStatusResponse;

    let t = theme::get();
    let mut inout = out
        .prepare_for_terminal_input()
        .context("Human input required - run this in a terminal")?;

View on GitHub (pinned to 58e5313667)