{"record":{"id":"98854f850aee0fb4","repo":"RyanCodrai/turbovec","slug":"embedder-returned-vectors-shape-0-vectors-for","errorCode":null,"errorMessage":"embedder returned {vectors.shape[0]} vectors for {n_texts} texts","messagePattern":"embedder returned (.+?) vectors for (.+?) texts","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"turbovec-python/python/turbovec/langchain.py","lineNumber":198,"sourceCode":"        return lambda sim: (sim + 1.0) / 2.0\n\n    # ---- Embedder-output validation -----------------------------------\n\n    @staticmethod\n    def _check_embedded_batch(vectors: np.ndarray, n_texts: int) -> None:\n        \"\"\"Validate the shape of an embedder's document-batch output.\n\n        Only 2D outputs are inspected here — any other ndim falls through\n        to ``_store_texts_and_vectors``, whose existing guard names the bad\n        dimensionality directly. Without the row-count check, a misbehaving\n        embedder that returns fewer vectors than texts surfaces downstream\n        as an id-count mismatch (or an IndexError during intra-batch\n        dedup) that never names the embedder as the cause.\n        \"\"\"\n        if vectors.ndim != 2:\n            return\n        if vectors.shape[0] != n_texts:\n            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(","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec-python/python/turbovec/langchain.py#L180-L216","documentation":"Raised in _check_embedded_batch when a 2D embedder output has a different row count than the number of input texts — a misbehaving embedder returned fewer (or more) vectors than texts. Without this check the mismatch surfaces downstream as an id-count error or IndexError during dedup that never names the embedder as the cause.","triggerScenarios":"Thrown at turbovec-python/python/turbovec/langchain.py:198 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix or replace the embedder — a conforming Embeddings.embed_documents returns exactly one vector per text.","Check for batch-size truncation in wrapper embedders (e.g. API limits silently dropping rows).","Catch the ValueError in ingestion code to flag the embedder as the failing component."],"exampleFix":null,"handlingStrategy":"validation","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-14T00:17:10.932Z"}