{"record":{"id":"f538ea8e88a5cb24","repo":"tirth8205/code-review-graph","slug":"voyage-api-returned-len-data-embeddings-for-le","errorCode":null,"errorMessage":"Voyage API returned {len(data)} embeddings for {len(texts)} inputs with no index field — refusing to misalign vectors.","messagePattern":"Voyage API returned (.+?) embeddings for (.+?) inputs with no index field — refusing to misalign vectors\\.","errorType":"http","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"code_review_graph/embeddings.py","lineNumber":764,"sourceCode":"                    raise RuntimeError(\"Voyage API returned empty data\")\n\n                any_has_index = any(\"index\" in item for item in data)\n                all_int_index = all(\n                    isinstance(item.get(\"index\"), int) for item in data\n                )\n                if all_int_index:\n                    expected = set(range(len(texts)))\n                    indices = [int(item[\"index\"]) for item in data]\n                    if len(set(indices)) != len(indices) or set(indices) != expected:\n                        raise RuntimeError(\n                            \"Voyage API returned malformed indices \"\n                            f\"(got {indices}, expected permutation of \"\n                            f\"0..{len(texts) - 1}) — refusing to misalign vectors.\"\n                        )\n                    data = sorted(data, key=lambda item: int(item[\"index\"]))\n                elif not any_has_index:\n                    if len(data) != len(texts):\n                        raise RuntimeError(\n                            f\"Voyage API returned {len(data)} embeddings for \"\n                            f\"{len(texts)} inputs with no index field — \"\n                            \"refusing to misalign vectors.\"\n                        )\n                else:\n                    raise RuntimeError(\n                        \"Voyage API returned mixed indexed/unindexed data — \"\n                        \"refusing to misalign vectors.\"\n                    )\n\n                return [item[\"embedding\"] for item in data]\n\n            except Exception as e:\n                is_retryable = False\n                if isinstance(e, urllib.error.HTTPError):\n                    is_retryable = e.code == 429 or 500 <= e.code < 600\n                elif isinstance(e, (\n                    urllib.error.URLError,","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/tirth8205/code-review-graph/blob/b58668751ab0c7670c078cf7cbd4d1f5b8e54f81/code_review_graph/embeddings.py#L746-L782","documentation":"No item in the response carries an 'index' field and the number of returned embeddings differs from the number of input texts. Without indices the provider cannot safely map vectors to texts, so it refuses rather than guess.","triggerScenarios":"Calling embed() with N texts where the API returns M != N embeddings and omits index fields — typically dropped rows from a proxy or partial batch handling.","commonSituations":"Proxy/gateway filtering empty-string inputs differently than the client, upstream deduplication of identical texts, or batch-size mismatch bugs in custom base-url setups.","solutions":["Retry with a smaller batch","Compare the exact texts sent vs count returned; look for empty strings or duplicates being dropped","Test against the real Voyage endpoint without CRG_VOYAGE_BASE_URL override","Report the count mismatch with the request payload"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"null","typeGuard":null,"tryCatchPattern":"try:\n    vecs = provider.embed(texts)\nexcept RuntimeError as e:\n    if \"no index field\" in str(e):\n        vecs = provider.embed(texts)\n    else:\n        raise","preventionTips":["Test custom base URLs against real Voyage behavior before relying on them","Avoid sending empty or whitespace-only texts that intermediaries may drop","Retry once before failing the whole embed job"],"tags":["voyage","embeddings","data-integrity","count-mismatch"],"backgroundTag":"embedding-response-misalignment","analyzedSha":"b58668751ab0c7670c078cf7cbd4d1f5b8e54f81","analyzedAt":"2026-08-28T13:19:08.966Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}