gitbutlerapp/gitbutler · error · anyhow::Error

Unsupported AI provider '{value}'

Error message

Unsupported AI provider '{value}'

What it means

The but-napi AI configuration maps a provider string onto `LLMProviderKind` via `from_git_config_value`. Only OpenAi, Anthropic, Ollama, and LMStudio are accepted; every other string — including near-misses and providers the domain enum may know but NAPI does not expose — is rejected by `provider()`.

Source

Thrown at crates/but-napi/src/ai.rs:108

        anthropic_model: configuration.anthropic.model,
        anthropic_has_api_key,
        ollama_endpoint: configuration.ollama.endpoint,
        ollama_model: configuration.ollama.model,
        lmstudio_endpoint: configuration.lmstudio.endpoint,
        lmstudio_model: configuration.lmstudio.model,
        is_configured,
    })
}

fn provider(value: &str) -> Result<LLMProviderKind> {
    match LLMProviderKind::from_git_config_value(value) {
        Some(
            provider @ (LLMProviderKind::OpenAi
            | LLMProviderKind::Anthropic
            | LLMProviderKind::Ollama
            | LLMProviderKind::LMStudio),
        ) => Ok(provider),
        _ => bail!("Unsupported AI provider '{value}'"),
    }
}

fn key_option(provider: &str, value: &str) -> Result<CredentialsKeyOption> {
    CredentialsKeyOption::from_git_config_value(value)
        .with_context(|| format!("Unsupported {provider} credential source '{value}'"))
}

fn submitted_key(value: Option<String>) -> Option<String> {
    value.and_then(|value| {
        let value = value.trim();
        (!value.is_empty()).then(|| value.to_string())
    })
}

fn validate_update(
    update: &AiConfigurationUpdate,
    openai_has_key: bool,

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Set provider to one of OpenAI, Anthropic, Ollama, or LMStudio using the exact spelling `from_git_config_value` accepts
  2. Update the app/JS layer so its provider list matches the installed native module version
  3. Trim whitespace and fix casing in the value before submitting the update

Example fix

// before
await ai.updateAiConfig({ provider: 'azure-openai' }); // bails

// after: one of the supported provider ids
await ai.updateAiConfig({ provider: 'openai' }); // openai | anthropic | ollama | lmstudio
Defensive patterns

Strategy: validation

Validate before calling

// TypeScript: validate against the supported provider set before the call
const SUPPORTED_PROVIDERS = ['openai', 'anthropic', 'ollama', 'lmstudio'] as const;
if (!SUPPORTED_PROVIDERS.includes(update.provider as never)) {
  throw new Error(`Unsupported AI provider '${update.provider}'`);
}
await ai.updateAiConfig(update);

Type guard

// TypeScript
const SUPPORTED_PROVIDERS = ['openai', 'anthropic', 'ollama', 'lmstudio'] as const;
type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
function isSupportedProvider(v: string): v is SupportedProvider {
  return (SUPPORTED_PROVIDERS as readonly string[]).includes(v.trim().toLowerCase());
}

Try / catch

Catch the NAPI error, read the unsupported value from the message, and re-render the provider selector constrained to the supported list (aligned with the installed native module version).

Prevention

When it happens

Trigger: Calling the AI configuration update through NAPI with `update.provider` set outside the supported set: typos like 'openai ' with whitespace, 'azure-openai', 'google', or an empty string.

Common situations: A frontend whose provider list is newer or older than the installed native module; users hand-editing the provider value in git config; provider ids copy-pasted from other tools.

Related errors


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