gitbutlerapp/gitbutler · warning · anyhow::Error
Could not determine selected AI provider
Error message
Could not determine selected AI provider
What it means
AI provider configuration prompts for one of OpenAI/Anthropic/Ollama/LM Studio/OpenRouter via prompt_select; the error is thrown when the picker yields no selection (cancelled/aborted). No provider means no subsequent key/model prompts can run, so configuration stops.
Source
Thrown at crates/but/src/command/config.rs:1582
scope: AiScope,
) -> Result<()> {
let t = theme::get();
let mut inout = out
.prepare_for_terminal_input()
.context("Human input required - run this in a terminal")?;
let providers = nonempty::nonempty![
("OpenAI", LLMProviderKind::OpenAi),
("Anthropic", LLMProviderKind::Anthropic),
("Ollama", LLMProviderKind::Ollama),
("LM Studio", LLMProviderKind::LMStudio),
("OpenRouter", LLMProviderKind::OpenRouter)
];
let provider = inout
.prompt_select("Select an AI provider", &providers)?
.cloned()
.ok_or_else(|| anyhow::anyhow!("Could not determine selected AI provider"))?;
match provider {
LLMProviderKind::OpenAi => {
let key_options = nonempty::nonempty![
("Use GitButler API", AiKeyOption::ButlerApi),
("Bring your own key", AiKeyOption::BringYourOwn)
];
let key_option = inout
.prompt_select("Select OpenAI credential source", &key_options)?
.copied()
.ok_or_else(|| anyhow::anyhow!("Could not determine OpenAI credential source"))?;
let model = inout.prompt("Preferred OpenAI model (leave empty for default):")?;
let endpoint = inout.prompt("Custom endpoint URL (optional):")?;
let secret = if matches!(key_option, AiKeyOption::BringYourOwn) {
Some(
inoutView on GitHub (pinned to caf1f223d3)
Solutions
- Re-run and confirm a provider with Enter — for Ollama/LM Studio no API key is needed, they are the quickest to set up locally.
- Have your API key (or GitButler account choice) ready before starting, since follow-up prompts ask for it.
- Remember Esc aborts the whole flow and surfaces as this error.
Defensive patterns
Strategy: try-catch
Try / catch
match configure_ai(out).await {
Err(e) if e.to_string().contains("Could not determine selected AI provider") => {
println!("AI configuration cancelled; existing settings unchanged."); Ok(())
}
other => other,
} Prevention
- Know your provider beforehand; Ollama/LM Studio need no keys.
- Complete the flow in one pass — cancellation discards prior prompts.
When it happens
Trigger: Running `but config` AI setup and aborting the provider picker with Esc before confirming an entry.
Common situations: User wants to check pricing/availability of a provider first; accidental Esc; exploring the config menu without intent to change anything.
Related errors
- Could not determine which forge provider to authenticate wit
- Could not determine authentication method
- Could not determine which accounts to delete
- 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/675f5225b8de32da.
Report an issue: GitHub.