tirth8205/code-review-graph · error · ValueError
Unknown embedding provider '{name}'. Valid: local, openai, g
Error message
Unknown embedding provider '{name}'. Valid: local, openai, google, minimax, voyage What it means
get_provider() validates the provider name against a fixed allowlist (local, openai, google, minimax, voyage) after lowercasing/trimming. Any other non-empty name raises before any provider is constructed.
Source
Thrown at code_review_graph/embeddings.py:906
CRG_OPENAI_API_KEY + CRG_OPENAI_BASE_URL + CRG_OPENAI_MODEL
env vars (or the ``model`` arg). The egress warning is
skipped when the base URL points to localhost.
Cloud providers emit a one-time stderr warning before use
unless ``CRG_ACCEPT_CLOUD_EMBEDDINGS=1`` is set. See: #174
model: Model name/path to use. For local provider this is any
sentence-transformers compatible model. Falls back to
CRG_EMBEDDING_MODEL env var, then to all-MiniLM-L6-v2.
For Google provider this is a Gemini model ID.
For OpenAI provider this overrides CRG_OPENAI_MODEL.
For Voyage provider this overrides CRG_VOYAGE_MODEL.
Raises:
ValueError: If the provider name is not one of the known providers,
or if required environment variables are missing.
"""
name = provider.strip().lower() if provider else ""
if name and name not in _VALID_PROVIDERS:
raise ValueError(
f"Unknown embedding provider '{name}'. "
"Valid: local, openai, google, minimax, voyage"
)
# When no explicit provider is given but OpenAI-compatible env vars are
# configured, default to the openai provider so MCP tool calls that omit
# the optional `provider` parameter still use the configured backend
# (#551).
if (
provider is None
and os.environ.get("CRG_OPENAI_API_KEY")
and os.environ.get("CRG_OPENAI_BASE_URL")
):
name = "openai"
if name == "openai":
api_key = os.environ.get("CRG_OPENAI_API_KEY")
base_url = os.environ.get("CRG_OPENAI_BASE_URL")View on GitHub (pinned to b58668751a)
Solutions
- Set provider to one of: local, openai, google, minimax, voyage
- For OpenAI-compatible endpoints, use provider='openai' with CRG_OPENAI_BASE_URL pointing at the vendor
- Fix typos/whitespace in CRG_EMBEDDING_PROVIDER
- Check _VALID_PROVIDERS in the installed version if names changed
Example fix
# before provider="azure" # after provider="openai" # + CRG_OPENAI_BASE_URL=https://your-endpoint/v1
Defensive patterns
Strategy: validation
Validate before calling
VALID = {"local", "openai", "google", "minimax", "voyage"}
name = (provider or "").strip().lower()
if name and name not in VALID:
raise ValueError(f"unsupported provider {name!r}; pick from {sorted(VALID)}") Type guard
def is_valid_provider(name: str) -> bool:
return (name or "").strip().lower() in {"local", "openai", "google", "minimax", "voyage"} Try / catch
try:
store = get_provider(provider)
except ValueError as e:
if "Unknown embedding provider" in str(e):
# fall back to local embeddings
store = get_provider("local")
else:
raise Prevention
- Centralize provider selection in one configvalidated spot
- For OpenAI-compatible vendors use 'openai' + CRG_OPENAI_BASE_URL, never the vendor name
- Fail fast on unknown provider in CLI arg parsing
When it happens
Trigger: Passing provider='azure' or similar to get_provider()/EmbeddingStore, or a CRG_EMBEDDING_PROVIDER env var with a typo like 'openai ' (whitespace is trimmed, but 'opennai' fails).
Common situations: Assuming an arbitrary OpenAI-compatible vendor name is accepted, typos in env config, or expecting an old provider name after a rename.
Understand the failure class
Background: "Invalid configuration value" and "Unsupported/Unknown setting value" errors: why libraries reject your config strings, numbers, and types — this error's family across 30 libraries.
Related errors
- Missing required environment variable(s) for the OpenAI embe
- MINIMAX_API_KEY environment variable is required for the Min
- VOYAGE_API_KEY environment variable is required for the Voya
- GOOGLE_API_KEY environment variable is required for the Goog
- Embedding refresh requires an explicit provider and model.
AI-assisted analysis of tirth8205/code-review-graph@b58668751a (2026-08-28).
Data as JSON: /api/errors/fefddf1f530cbee8.
Report an issue: GitHub.