{"record":{"id":"675f5225b8de32da","repo":"gitbutlerapp/gitbutler","slug":"could-not-determine-selected-ai-provider","errorCode":null,"errorMessage":"Could not determine selected AI provider","messagePattern":"Could not determine selected AI provider","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/but/src/command/config.rs","lineNumber":1582,"sourceCode":"    scope: AiScope,\n) -> Result<()> {\n    let t = theme::get();\n\n    let mut inout = out\n        .prepare_for_terminal_input()\n        .context(\"Human input required - run this in a terminal\")?;\n\n    let providers = nonempty::nonempty![\n        (\"OpenAI\", LLMProviderKind::OpenAi),\n        (\"Anthropic\", LLMProviderKind::Anthropic),\n        (\"Ollama\", LLMProviderKind::Ollama),\n        (\"LM Studio\", LLMProviderKind::LMStudio),\n        (\"OpenRouter\", LLMProviderKind::OpenRouter)\n    ];\n    let provider = inout\n        .prompt_select(\"Select an AI provider\", &providers)?\n        .cloned()\n        .ok_or_else(|| anyhow::anyhow!(\"Could not determine selected AI provider\"))?;\n\n    match provider {\n        LLMProviderKind::OpenAi => {\n            let key_options = nonempty::nonempty![\n                (\"Use GitButler API\", AiKeyOption::ButlerApi),\n                (\"Bring your own key\", AiKeyOption::BringYourOwn)\n            ];\n            let key_option = inout\n                .prompt_select(\"Select OpenAI credential source\", &key_options)?\n                .copied()\n                .ok_or_else(|| anyhow::anyhow!(\"Could not determine OpenAI credential source\"))?;\n\n            let model = inout.prompt(\"Preferred OpenAI model (leave empty for default):\")?;\n            let endpoint = inout.prompt(\"Custom endpoint URL (optional):\")?;\n\n            let secret = if matches!(key_option, AiKeyOption::BringYourOwn) {\n                Some(\n                    inout","sourceCodeStart":1564,"sourceCodeEnd":1600,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/config.rs#L1564-L1600","documentation":"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.","triggerScenarios":"Running `but config` AI setup and aborting the provider picker with Esc before confirming an entry.","commonSituations":"User wants to check pricing/availability of a provider first; accidental Esc; exploring the config menu without intent to change anything.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match configure_ai(out).await {\n    Err(e) if e.to_string().contains(\"Could not determine selected AI provider\") => {\n        println!(\"AI configuration cancelled; existing settings unchanged.\"); Ok(())\n    }\n    other => other,\n}","preventionTips":["Know your provider beforehand; Ollama/LM Studio need no keys.","Complete the flow in one pass — cancellation discards prior prompts."],"tags":["interactive","picker","ai-config","llm"],"backgroundTag":"prompt-cancelled","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}