tirth8205/code-review-graph · error · RuntimeError
Voyage API error: {msg}
Error message
Voyage API error: {msg} What it means
Raised when the Voyage embeddings API response JSON contains an 'error' key. The provider surfaces the upstream error message so callers can distinguish API-side failures (bad key, invalid model, rate limits) from local issues.
Source
Thrown at code_review_graph/embeddings.py:742
parsed = _json.loads(err_body)
if isinstance(parsed, dict) and "error" in parsed:
err_obj = parsed["error"]
err_msg = (
err_obj.get("message", err_msg)
if isinstance(err_obj, dict) else str(err_obj)
)
except Exception: # nosec B110
pass
raise RuntimeError(
f"Voyage API HTTP {http_err.code}: {err_msg}"
) from http_err
response = _json.loads(raw)
if "error" in response:
err = response["error"]
msg = err.get("message", "unknown") if isinstance(err, dict) else str(err)
raise RuntimeError(f"Voyage API error: {msg}")
data = response.get("data", [])
if not data:
raise RuntimeError("Voyage API returned empty data")
any_has_index = any("index" in item for item in data)
all_int_index = all(
isinstance(item.get("index"), int) for item in data
)
if all_int_index:
expected = set(range(len(texts)))
indices = [int(item["index"]) for item in data]
if len(set(indices)) != len(indices) or set(indices) != expected:
raise RuntimeError(
"Voyage API returned malformed indices "
f"(got {indices}, expected permutation of "
f"0..{len(texts) - 1}) — refusing to misalign vectors."
)View on GitHub (pinned to b58668751a)
Solutions
- Check the embedded msg: invalid API key → fix VOYAGE_API_KEY; model not found → fix CRG_VOYAGE_MODEL
- Verify the model name against Voyage's current model list
- Add retry with exponential backoff for rate-limit errors
- Inspect raw response by enabling debug logging if msg is 'unknown'
Example fix
# before VOYAGE_API_KEY=sk-typo voyage-embed ... # after VOYAGE_API_KEY=sk-...valid... voyage-embed ...
Defensive patterns
Strategy: retry
Validate before calling
import os
assert os.environ.get("VOYAGE_API_KEY"), "VOYAGE_API_KEY not set"
assert os.environ.get("CRG_VOYAGE_MODEL"), "model not set" Type guard
def is_voyage_api_error(exc: RuntimeError) -> bool:
return str(exc).startswith("Voyage API error:") Try / catch
try:
vecs = provider.embed(texts)
except RuntimeError as e:
if str(e).startswith("Voyage API error:"):
log.warning("voyage api: %s", e); time.sleep(backoff); vecs = provider.embed(texts)
else:
raise Prevention
- Validate VOYAGE_API_KEY and model before starting an embed run
- Use a model name confirmed against Voyage's docs
- Wrap batch embeds in bounded retry with exponential backoff
When it happens
Trigger: Calling embed() or embed_query() on VoyageEmbeddingProvider and the HTTP response body parses as JSON containing an 'error' object — e.g. invalid VOYAGE_API_KEY, unknown model name, rate limiting, or malformed input text.
Common situations: Expired/typo'd VOYAGE_API_KEY, deprecated/renamed model in CRG_VOYAGE_MODEL, hitting Voyage rate limits during a large embed run, or pointing CRG_VOYAGE_BASE_URL at a proxy that returns API-style error JSON.
Related errors
- Voyage API HTTP {http_err.code}: {err_msg}
- MiniMax API error: {base_resp.get('status_msg', 'unknown')}
- OpenAI API HTTP {http_err.code}: {err_msg}
- OpenAI API error: {msg}
- Voyage API returned empty data
AI-assisted analysis of tirth8205/code-review-graph@b58668751a (2026-08-28).
Data as JSON: /api/errors/3f0705f0d1916da6.
Report an issue: GitHub.