{"record":{"id":"3f0705f0d1916da6","repo":"tirth8205/code-review-graph","slug":"voyage-api-error-msg","errorCode":null,"errorMessage":"Voyage API error: {msg}","messagePattern":"Voyage API error: (.+?)","errorType":"http","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"code_review_graph/embeddings.py","lineNumber":742,"sourceCode":"                        parsed = _json.loads(err_body)\n                        if isinstance(parsed, dict) and \"error\" in parsed:\n                            err_obj = parsed[\"error\"]\n                            err_msg = (\n                                err_obj.get(\"message\", err_msg)\n                                if isinstance(err_obj, dict) else str(err_obj)\n                            )\n                    except Exception:  # nosec B110\n                        pass\n                    raise RuntimeError(\n                        f\"Voyage API HTTP {http_err.code}: {err_msg}\"\n                    ) from http_err\n\n                response = _json.loads(raw)\n\n                if \"error\" in response:\n                    err = response[\"error\"]\n                    msg = err.get(\"message\", \"unknown\") if isinstance(err, dict) else str(err)\n                    raise RuntimeError(f\"Voyage API error: {msg}\")\n\n                data = response.get(\"data\", [])\n                if not data:\n                    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                        )","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/tirth8205/code-review-graph/blob/b58668751ab0c7670c078cf7cbd4d1f5b8e54f81/code_review_graph/embeddings.py#L724-L760","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'"],"exampleFix":"# before\nVOYAGE_API_KEY=sk-typo voyage-embed ...\n# after\nVOYAGE_API_KEY=sk-...valid... voyage-embed ...","handlingStrategy":"retry","validationCode":"import os\nassert os.environ.get(\"VOYAGE_API_KEY\"), \"VOYAGE_API_KEY not set\"\nassert os.environ.get(\"CRG_VOYAGE_MODEL\"), \"model not set\"","typeGuard":"def is_voyage_api_error(exc: RuntimeError) -> bool:\n    return str(exc).startswith(\"Voyage API error:\")","tryCatchPattern":"try:\n    vecs = provider.embed(texts)\nexcept RuntimeError as e:\n    if str(e).startswith(\"Voyage API error:\"):\n        log.warning(\"voyage api: %s\", e); time.sleep(backoff); vecs = provider.embed(texts)\n    else:\n        raise","preventionTips":["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"],"tags":["voyage","embeddings","api-error","remote-api"],"backgroundTag":"embedding-api-error","analyzedSha":"b58668751ab0c7670c078cf7cbd4d1f5b8e54f81","analyzedAt":"2026-08-28T13:19:08.966Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}