tirth8205/code-review-graph · error · RuntimeError
Voyage API returned empty data
Error message
Voyage API returned empty data
What it means
The Voyage API returned a 200-style response with no 'data' array (or an empty one). The provider refuses to return an empty embedding list because callers assume one vector per input text.
Source
Thrown at code_review_graph/embeddings.py:746
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."
)
data = sorted(data, key=lambda item: int(item["index"]))
elif not any_has_index:
if len(data) != len(texts):
raise RuntimeError(View on GitHub (pinned to b58668751a)
Solutions
- Log and retry once — often transient
- Confirm the request actually included non-empty texts
- If using a custom CRG_VOYAGE_BASE_URL, curl the endpoint manually and verify the 'data' array is present
- Report to Voyage if reproducible with a minimal request
Defensive patterns
Strategy: retry
Validate before calling
if not texts:
raise ValueError("refusing to call embed() with no texts") Try / catch
try:
vecs = provider.embed(texts)
except RuntimeError as e:
if "empty data" in str(e):
vecs = provider.embed(texts) # one retry
else:
raise Prevention
- Never pass an empty texts list
- Keep batches small enough to avoid truncation
- Alert on repeated empty-data responses — likely a proxy issue
When it happens
Trigger: Calling embed()/embed_query() where the parsed Voyage response has no 'data' key or data == [] — server-side truncation, proxy stripping fields, or an empty input batch.
Common situations: Misconfigured CRG_VOYAGE_BASE_URL proxy that reformats responses, sending an empty texts list, or transient API anomalies/outage behavior.
Related errors
- OpenAI API returned empty data
- Voyage API HTTP {http_err.code}: {err_msg}
- Voyage API error: {msg}
- Voyage API returned malformed indices (got {indices}, expect
- Voyage API returned {len(data)} embeddings for {len(texts)}
AI-assisted analysis of tirth8205/code-review-graph@b58668751a (2026-08-28).
Data as JSON: /api/errors/1b4d93aa398d0716.
Report an issue: GitHub.