{"record":{"id":"12713670d2b35a39","repo":"MemPalace/mempalace","slug":"query-requires-query-embeddings-127136","errorCode":null,"errorMessage":"query requires query_embeddings","messagePattern":"query requires query_embeddings","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/pgvector.py","lineNumber":1084,"sourceCode":"            embeddings=outer_embeds if spec.embeddings else None,\n        )\n\n    def query(\n        self,\n        *,\n        query_texts=None,\n        query_embeddings=None,\n        n_results=10,\n        where=None,\n        where_document=None,\n        include=None,\n    ) -> QueryResult:\n        if query_texts is not None:\n            raise ValueError(\n                \"pgvector requires query_embeddings; use palace.get_collection wrapper\"\n            )\n        if query_embeddings is None:\n            raise ValueError(\"query requires query_embeddings\")\n        if not query_embeddings:\n            raise ValueError(\"query input must be a non-empty list\")\n        _validate_where(where)\n        _validate_where(where_document)\n        if _requires_local_filter(where, where_document):\n            return self._query_local_exact(\n                query_embeddings=query_embeddings,\n                n_results=n_results,\n                where=where,\n                where_document=where_document,\n                include=include,\n            )\n        self._ensure_open()\n        if not self._table_exists():\n            if self._marker_exists():\n                raise CollectionNotInitializedError(self._collection_name)\n            return QueryResult.empty(\n                num_queries=len(query_embeddings),","sourceCodeStart":1066,"sourceCodeEnd":1102,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/pgvector.py#L1066-L1102","documentation":"PgVectorCollection.query() needs precomputed vectors because the backend stores and searches embeddings only; it has no embedder. If neither query_texts nor query_embeddings is supplied, the call is a programming error and raises this ValueError before any SQL runs.","triggerScenarios":"Calling query() with no arguments, or passing only n_results/where/include and forgetting the vectors: col.query(n_results=5, where={\"wing\": \"work\"}).","commonSituations":"Refactoring a call site so the embeddings variable becomes None under some branch; optional-chaining bugs where query_embeddings=query_embs is skipped when query_embs is None.","solutions":["Pass query_embeddings=[vector] (list of 1D float lists) computed by your embedder.","If you only have text, use the palace.get_collection() wrapper and pass query_texts instead.","Guard the call: skip or early-return when the embeddings variable is None."],"exampleFix":"# before\ncol.query(n_results=5, where=filters)\n\n# after\ncol.query(query_embeddings=[embedder.embed(\"hello\")], n_results=5, where=filters)","handlingStrategy":"validation","validationCode":"if not query_embeddings:\n    raise ValueError(\"cannot query without embeddings\")\ncol.query(query_embeddings=query_embeddings, n_results=5)","typeGuard":"def has_query_vectors(qe) -> bool:\n    return qe is not None and len(qe) > 0 and all(v is not None and len(v) > 0 for v in qe)","tryCatchPattern":"try:\n    col.query(query_embeddings=vecs, n_results=5)\nexcept ValueError as e:\n    if \"query_embeddings\" in str(e) or \"non-empty\" in str(e):\n        logger.warning(\"skipping query: no embeddings\")\n        return None\n    raise","preventionTips":["Early-return when the embeddings variable is None or empty.","Keep embedder output and query calls adjacent so one is never supplied without the other."],"tags":["pgvector","validation","missing-argument"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}