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
- Use "fallback" or "round-robin" (or "baml-fallback"/"baml-round-robin") exactly.
- Fix casing — variants are lowercase.
- 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
- Only round-robin and fallback strategies exist — validate against them.
- Beware of names from other frameworks ("retry", "random" are not supported).
- Spell strategies lowercase with hyphens.
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
- Invalid client provider: {}
- Invalid OpenAI client provider variant: {}
- undefined variant: {enum_name_str}.{variant_str}
- undefined enum: {enum_name}
- undefined variant: {enum_name}.{variant}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/93abb7d92c3ea78d.
Report an issue: GitHub.