{"record":{"id":"8c24fffcd5938759","repo":"RyanCodrai/turbovec","slug":"query-embedding-should-be-a-non-empty-list-of-floa","errorCode":null,"errorMessage":"query_embedding should be a non-empty list of floats.","messagePattern":"query_embedding should be a non-empty list of floats\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"turbovec-python/python/turbovec/haystack.py","lineNumber":614,"sourceCode":"        when the filter is selective.\n\n        :raises ValueError: if ``query_embedding`` is empty or does not\n            hold numbers, if its dim does not match the store's, or if\n            ``top_k`` is negative. (``top_k=-1`` is rejected here where\n            ``InMemoryDocumentStore`` returns ``n - 1`` documents — a\n            negative count is a caller bug, not a request.)\n        \"\"\"\n        # `return_embedding` is accepted but we never have the full\n        # embedding to populate; left as-is for signature parity.\n        _ = return_embedding  # noqa: F841\n\n        # Up-front validation, matching the reference: an empty or\n        # non-numeric query embedding is a caller error regardless of\n        # whether the store happens to be empty (issue #301). `Real`\n        # rather than the reference's `isinstance(..., float)` so numpy\n        # scalars and ints are accepted.\n        if len(query_embedding) == 0 or not isinstance(query_embedding[0], Real):\n            raise ValueError(\"query_embedding should be a non-empty list of floats.\")\n\n        if self.count_documents() == 0:\n            return []\n\n        qvec = np.asarray(query_embedding, dtype=np.float32)\n        if qvec.ndim == 1:\n            qvec = qvec[None, :]\n        # By this point n_documents > 0, so the index has a committed dim.\n        expected_dim = self._index.dim\n        if qvec.shape[1] != expected_dim:\n            raise ValueError(\n                f\"query_embedding dim {qvec.shape[1]} does not match store dim {expected_dim}\"\n            )\n        # Cosine mode: normalize the query so the raw score against unit\n        # document vectors is true cosine similarity.\n        if self._vectors_normalized:\n            qvec = l2_normalize_rows(qvec)\n        if not qvec.flags[\"C_CONTIGUOUS\"]:","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec-python/python/turbovec/haystack.py#L596-L632","documentation":"Raised in embedding_retrieval when query_embedding is empty or its first element is not a Real number. Matches the reference store's up-front validation (issue #301): a bad query vector is a caller error even if the store is empty. Real (not float) is accepted so numpy scalars and ints work.","triggerScenarios":"Thrown at turbovec-python/python/turbovec/haystack.py:614 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-empty list of numeric floats — the output of the embedder's run() on the query text.","Check the embedding pipeline: an empty or non-numeric result means the embedder failed or was fed the wrong input.","Catch the ValueError in retrieval components to distinguish caller errors from empty-result cases (an empty store returns [])."],"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"}