BoundaryML/baml · error

Invalid strategy client provider variant: {}

Error message

Invalid strategy client provider variant: {}

What it means

StrategyClientProvider::from_str parses strategy client names and accepts only "round-robin" and "fallback" (plus baml- aliases at the ClientProvider level). Any other string raises "Invalid strategy client provider variant: {s}".

Source

Thrown at engine/baml-lib/llm-client/src/clientspec.rs:181

            "openai-transcriptions" => Ok(OpenAIClientProviderVariant::Transcriptions),
            "openai-generic" => Ok(OpenAIClientProviderVariant::Generic),
            "openrouter" => Ok(OpenAIClientProviderVariant::OpenRouter),
            _ => Err(anyhow::anyhow!(
                "Invalid OpenAI client provider variant: {}",
                s
            )),
        }
    }
}

impl std::str::FromStr for StrategyClientProvider {
    type Err = anyhow::Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "round-robin" => Ok(StrategyClientProvider::RoundRobin),
            "fallback" => Ok(StrategyClientProvider::Fallback),
            _ => Err(anyhow::anyhow!(
                "Invalid strategy client provider variant: {}",
                s
            )),
        }
    }
}

impl ClientProvider {
    pub fn allowed_providers() -> &'static [&'static str] {
        &[
            "openai",
            "openai-generic",
            "azure-openai",
            "openai-responses",
            "openai-transcriptions",
            "anthropic",
            "ollama",
            "openrouter",

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Use "fallback" or "round-robin" (or "baml-fallback"/"baml-round-robin") exactly.
  2. Fix casing — variants are lowercase.
  3. Implement custom strategies via BAML's other mechanisms instead of inventing a strategy name.

Example fix

// before
provider "RoundRobin"
// after
provider "round-robin"
Defensive patterns

Strategy: try-catch

Validate before calling

if (!["round-robin","fallback"].includes(s)) throw new Error(`unknown strategy: ${s}`);

Try / catch

match s.parse::<StrategyClientProvider>() {
    Ok(v) => v,
    Err(e) => { eprintln!("{e}"); StrategyClientProvider::Fallback }
}

Prevention

When it happens

Trigger: Parsing a strategy provider string like "retry", "random", or "best-of" that the strategy enum does not support.

Common situations: Expecting a retry strategy provider that doesn't exist; typos like "roundrobin" or "Round-Robin"; copying strategy names from other LLM frameworks.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/93abb7d92c3ea78d. Report an issue: GitHub.