{"record":{"id":"d1783c2fa111c267","repo":"tirth8205/code-review-graph","slug":"embedding-refresh-requires-an-explicit-provider-an","errorCode":null,"errorMessage":"Embedding refresh requires an explicit provider and model.","messagePattern":"Embedding refresh requires an explicit provider and model\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"code_review_graph/embeddings.py","lineNumber":1341,"sourceCode":"    *,\n    provider: str,\n    model: str,\n) -> dict[str, int] | None:\n    \"\"\"Refresh a previously embedded graph under one exact provider identity.\n\n    This function is deliberately not called by default build paths.  Callers\n    must supply both provider and model explicitly.  A graph with no existing\n    vectors returns before provider resolution, so routine builds cannot load\n    a local model, contact a cloud service, or incur API cost.\n\n    Existing vectors must all use the identity resolved from the requested\n    provider/model (including the endpoint for OpenAI-compatible providers).\n    Refresh never silently migrates an index to another model or endpoint.\n    \"\"\"\n    provider = provider.strip().lower()\n    model = model.strip()\n    if not provider or not model:\n        raise ValueError(\n            \"Embedding refresh requires an explicit provider and model.\",\n        )\n\n    has_table = graph_store._conn.execute(\n        \"SELECT 1 FROM sqlite_master \"\n        \"WHERE type = 'table' AND name = 'embeddings'\",\n    ).fetchone()\n    if has_table is None:\n        return None\n    has_rows = graph_store._conn.execute(\n        \"SELECT 1 FROM embeddings LIMIT 1\",\n    ).fetchone()\n    if has_rows is None:\n        return None\n    try:\n        rows = graph_store._conn.execute(\n            \"SELECT DISTINCT provider FROM embeddings ORDER BY provider\",\n        ).fetchall()","sourceCodeStart":1323,"sourceCodeEnd":1359,"githubUrl":"https://github.com/tirth8205/code-review-graph/blob/b58668751ab0c7670c078cf7cbd4d1f5b8e54f81/code_review_graph/embeddings.py#L1323-L1359","documentation":"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.","triggerScenarios":"Calling refresh_embeddings(graph_store, provider='', model='') or omitting/blanking either argument (values are stripped before the check, so whitespace-only also fails).","commonSituations":"Calling refresh from a wrapper that reads unset env vars and passes empty strings, or assuming refresh inherits the provider from the stored index.","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)"],"exampleFix":"# before\nrefresh_embeddings(gs, provider=os.environ.get('P') or '', model=os.environ.get('M') or '')\n# after\nrefresh_embeddings(gs, provider='voyage', model='voyage-3-lite')","handlingStrategy":"validation","validationCode":"provider = (provider or \"\").strip()\nmodel = (model or \"\").strip()\nif not provider or not model:\n    raise ValueError(\"refresh requires explicit provider and model\")","typeGuard":null,"tryCatchPattern":"try:\n    refresh_embeddings(gs, provider=p, model=m)\nexcept ValueError as e:\n    if \"requires an explicit provider and model\" in str(e):\n        p, m = \"local\", \"minilm-l12-v2\"  # sane defaults\n        refresh_embeddings(gs, provider=p, model=m)\n    else:\n        raise","preventionTips":["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"],"tags":["embeddings","refresh","validation","config"],"backgroundTag":"invalid-configuration-value","analyzedSha":"b58668751ab0c7670c078cf7cbd4d1f5b8e54f81","analyzedAt":"2026-08-28T13:19:08.966Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}