{"record":{"id":"948aebde16804cd2","repo":"RyanCodrai/turbovec","slug":"embedder-returned-a-qvec-ndim-d-query-embedding","errorCode":null,"errorMessage":"embedder returned a {qvec.ndim}D query embedding; expected a single 1D vector","messagePattern":"embedder returned a (.+?)D query embedding; expected a single 1D vector","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"turbovec-python/python/turbovec/langchain.py","lineNumber":216,"sourceCode":"            raise ValueError(\n                f\"embedder returned {vectors.shape[0]} vectors for \"\n                f\"{n_texts} texts\"\n            )\n        if vectors.shape[1] == 0:\n            raise ValueError(\n                f\"embedder returned empty vectors (dim 0) for {n_texts} texts\"\n            )\n\n    def _validate_query_embedding(self, embedded: Any) -> np.ndarray:\n        \"\"\"Coerce an embedder's query output to a 1D float32 vector,\n        rejecting None and wrong-rank outputs with an error that names\n        the embedder (the raw values otherwise surface as opaque errors\n        from the index kernel).\"\"\"\n        if embedded is None:\n            raise ValueError(\"embedder returned None instead of a query embedding\")\n        qvec = np.asarray(embedded, dtype=np.float32)\n        if qvec.ndim != 1:\n            raise ValueError(\n                f\"embedder returned a {qvec.ndim}D query embedding; \"\n                \"expected a single 1D vector\"\n            )\n        return qvec\n\n    # ---- Write path ---------------------------------------------------\n\n    @staticmethod\n    def _normalize_ids(ids: list[str]) -> list[str]:\n        \"\"\"Return a fresh ``list[str]`` copy of ``ids`` with per-entry\n        ``None`` replaced by a generated UUID (matches the reference\n        InMemoryVectorStore and keeps None out of the JSON side-car,\n        where it would round-trip as the string ``\"null\"``).\n\n        Any other non-``str`` id raises ``TypeError``. This is a\n        deliberate deviation from the reference InMemoryVectorStore,\n        which accepts e.g. an ``int`` id and then corrupts it: JSON\n        persistence coerces every key to ``str``, so ``2`` and ``\"2\"``","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec-python/python/turbovec/langchain.py#L198-L234","documentation":"Raised in _validate_query_embedding when the embedder's query output converts to an array with rank other than 1 — e.g. a batch of vectors or nested lists — where a single 1D vector is required for one query. Named so the embedder is identified as the cause rather than an index-kernel error.","triggerScenarios":"Thrown at turbovec-python/python/turbovec/langchain.py:216 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use embed_query (single-vector) rather than embed_documents for queries, or index the batch output with [0].","Fix the embedder wrapper to return one flat vector per query.","Catch the ValueError in search code to flag the wrong-rank embedder output."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ccab9f325e6ce2a270a87daf01ae4e443bcf2d49","analyzedAt":"2026-09-06T08:39:18.516Z","contentChangedAt":"2026-09-06T08:39:18.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}