tirth8205/code-review-graph · error · ValueError
Embedding refresh requires an explicit provider and model.
Error message
Embedding refresh requires an explicit provider and model.
What it means
refresh_embeddings() requires both provider and model explicitly because refresh must never guess which embedding backend to rebuild with — a wrong guess would silently migrate the index to incompatible vectors.
Source
Thrown at code_review_graph/embeddings.py:1341
*,
provider: str,
model: str,
) -> dict[str, int] | None:
"""Refresh a previously embedded graph under one exact provider identity.
This function is deliberately not called by default build paths. Callers
must supply both provider and model explicitly. A graph with no existing
vectors returns before provider resolution, so routine builds cannot load
a local model, contact a cloud service, or incur API cost.
Existing vectors must all use the identity resolved from the requested
provider/model (including the endpoint for OpenAI-compatible providers).
Refresh never silently migrates an index to another model or endpoint.
"""
provider = provider.strip().lower()
model = model.strip()
if not provider or not model:
raise ValueError(
"Embedding refresh requires an explicit provider and model.",
)
has_table = graph_store._conn.execute(
"SELECT 1 FROM sqlite_master "
"WHERE type = 'table' AND name = 'embeddings'",
).fetchone()
if has_table is None:
return None
has_rows = graph_store._conn.execute(
"SELECT 1 FROM embeddings LIMIT 1",
).fetchone()
if has_rows is None:
return None
try:
rows = graph_store._conn.execute(
"SELECT DISTINCT provider FROM embeddings ORDER BY provider",
).fetchall()View on GitHub (pinned to b58668751a)
Solutions
- Pass explicit non-empty provider and model, e.g. refresh_embeddings(gs, provider='voyage', model='voyage-3-lite')
- Fix the upstream config so empty strings don't reach this API
- Use the same provider/model recorded in the embeddings table (SELECT DISTINCT provider FROM embeddings)
Example fix
# before
refresh_embeddings(gs, provider=os.environ.get('P') or '', model=os.environ.get('M') or '')
# after
refresh_embeddings(gs, provider='voyage', model='voyage-3-lite') Defensive patterns
Strategy: validation
Validate before calling
provider = (provider or "").strip()
model = (model or "").strip()
if not provider or not model:
raise ValueError("refresh requires explicit provider and model") Try / catch
try:
refresh_embeddings(gs, provider=p, model=m)
except ValueError as e:
if "requires an explicit provider and model" in str(e):
p, m = "local", "minilm-l12-v2" # sane defaults
refresh_embeddings(gs, provider=p, model=m)
else:
raise Prevention
- Never derive provider/model from possibly-unset env vars without defaults
- Record the embed-time provider/model in your own config so refresh can reuse it
- Treat blank strings from env .get() chains as missing
When it happens
Trigger: Calling refresh_embeddings(graph_store, provider='', model='') or omitting/blanking either argument (values are stripped before the check, so whitespace-only also fails).
Common situations: Calling refresh from a wrapper that reads unset env vars and passes empty strings, or assuming refresh inherits the provider from the stored index.
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
- OpenAI API returned empty data
- Unknown embedding provider '{name}'. Valid: local, openai, g
- 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
AI-assisted analysis of tirth8205/code-review-graph@b58668751a (2026-08-28).
Data as JSON: /api/errors/d1783c2fa111c267.
Report an issue: GitHub.