gitbutlerapp/gitbutler · warning · anyhow::Error

Could not determine Anthropic credential source

Error message

Could not determine Anthropic credential source

What it means

Anthropic equivalent of the OpenAI credential-source prompt: after selecting Anthropic as provider, a picker offers 'Use GitButler API' vs 'Bring your own key', and cancelling it (None result) raises this error before the model/API-key prompts run.

Source

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

                        .prompt_secret("Enter OpenAI API key:")?
                        .context("No API key provided. Aborting configuration.")?,
                )
            } else {
                None
            };

            apply_openai_config(repo, scope, key_option, model, endpoint, secret)?;
        }
        LLMProviderKind::Anthropic => {
            let key_options = nonempty::nonempty![
                ("Use GitButler API", AiKeyOption::ButlerApi),
                ("Bring your own key", AiKeyOption::BringYourOwn)
            ];
            let key_option = inout
                .prompt_select("Select Anthropic credential source", &key_options)?
                .copied()
                .ok_or_else(|| {
                    anyhow::anyhow!("Could not determine Anthropic credential source")
                })?;

            let model = inout.prompt("Preferred Anthropic model (leave empty for default):")?;
            let secret = if matches!(key_option, AiKeyOption::BringYourOwn) {
                Some(
                    inout
                        .prompt_secret("Enter Anthropic API key:")?
                        .context("No API key provided. Aborting configuration.")?,
                )
            } else {
                None
            };

            apply_anthropic_config(repo, scope, key_option, model, secret)?;
        }
        LLMProviderKind::Ollama => {
            let endpoint = inout.prompt("Ollama endpoint host:port (optional):")?;
            let model = inout.prompt("Preferred Ollama model (optional):")?;

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Choose 'Use GitButler API' to skip key handling.
  2. Or create an Anthropic key (console.anthropic.com), re-run, pick 'Bring your own key' and paste it.
  3. Re-run `but config` AI setup to restart the flow.
Defensive patterns

Strategy: try-catch

Try / catch

match configure_ai(out).await {
    Err(e) if e.to_string().contains("Anthropic credential source") => { Ok(()) }
    other => other,
}

Prevention

When it happens

Trigger: Selecting Anthropic in AI config, then aborting the 'Select Anthropic credential source' picker with Esc.

Common situations: User needs to create an Anthropic API key first; deciding between proxied and own key.

Related errors


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