RyanCodrai/turbovec · error · ValueError

embedder returned a {qvec.ndim}D query embedding; expected a

Error message

embedder returned a {qvec.ndim}D query embedding; expected a single 1D vector

What it means

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.

Source

Thrown at turbovec-python/python/turbovec/langchain.py:216

            raise ValueError(
                f"embedder returned {vectors.shape[0]} vectors for "
                f"{n_texts} texts"
            )
        if vectors.shape[1] == 0:
            raise ValueError(
                f"embedder returned empty vectors (dim 0) for {n_texts} texts"
            )

    def _validate_query_embedding(self, embedded: Any) -> np.ndarray:
        """Coerce an embedder's query output to a 1D float32 vector,
        rejecting None and wrong-rank outputs with an error that names
        the embedder (the raw values otherwise surface as opaque errors
        from the index kernel)."""
        if embedded is None:
            raise ValueError("embedder returned None instead of a query embedding")
        qvec = np.asarray(embedded, dtype=np.float32)
        if qvec.ndim != 1:
            raise ValueError(
                f"embedder returned a {qvec.ndim}D query embedding; "
                "expected a single 1D vector"
            )
        return qvec

    # ---- Write path ---------------------------------------------------

    @staticmethod
    def _normalize_ids(ids: list[str]) -> list[str]:
        """Return a fresh ``list[str]`` copy of ``ids`` with per-entry
        ``None`` replaced by a generated UUID (matches the reference
        InMemoryVectorStore and keeps None out of the JSON side-car,
        where it would round-trip as the string ``"null"``).

        Any other non-``str`` id raises ``TypeError``. This is a
        deliberate deviation from the reference InMemoryVectorStore,
        which accepts e.g. an ``int`` id and then corrupts it: JSON
        persistence coerces every key to ``str``, so ``2`` and ``"2"``

View on GitHub (pinned to ccab9f325e)

Solutions

  1. Use embed_query (single-vector) rather than embed_documents for queries, or index the batch output with [0].
  2. Fix the embedder wrapper to return one flat vector per query.
  3. Catch the ValueError in search code to flag the wrong-rank embedder output.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at turbovec-python/python/turbovec/langchain.py:216 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of RyanCodrai/turbovec@ccab9f325e (2026-09-06). Data as JSON: /api/errors/948aebde16804cd2. Report an issue: GitHub.