{"record":{"id":"e47d540c6bba4182","repo":"MemPalace/mempalace","slug":"query-input-must-be-a-non-empty-list-e47d54","errorCode":null,"errorMessage":"query input must be a non-empty list","messagePattern":"query input must be a non-empty list","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/qdrant.py","lineNumber":960,"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(\"qdrant requires query_embeddings; use palace.get_collection wrapper\")\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        if not self._remote_exists():\n            if self._marker_exists():\n                raise CollectionNotInitializedError(self._collection_name)\n            return QueryResult.empty(\n                num_queries=len(query_embeddings),\n                embeddings_requested=bool(include and \"embeddings\" in include),\n            )\n","sourceCodeStart":942,"sourceCodeEnd":978,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/qdrant.py#L942-L978","documentation":"Raised by QdrantCollection.query() when query_embeddings is an empty list ([]). Distinguishing 'no embeddings given' (135) from 'empty list', this guard prevents a zero-query response whose shape (empty vs per-query lists) would be ambiguous downstream.","triggerScenarios":"Calling query(query_embeddings=[]) — typically batch-search code that maps a list of queries to embeddings and the input list was empty (e.g. searching for zero candidate re-ranking queries).","commonSituations":"A rerank/batch-search loop receiving an empty candidate set and still calling query; list comprehension over an empty query list producing []; upstream dedup/filtering that removed all queries.","solutions":["Skip the call when there is nothing to search: if not queries: return []","Guard batch code: embeddings = [embed(q) for q in queries]; if embeddings: collection.query(query_embeddings=embeddings)","Treat empty input as a legitimate no-op at the caller's boundary rather than an error","Add a unit test for the empty-batch path so it stays a no-op"],"exampleFix":"# before\nresults = collection.query(query_embeddings=[embedder.embed(q) for q in queries])  # queries=[] -> ValueError\n// after\nembeddings = [embedder.embed(q) for q in queries]\nresults = collection.query(query_embeddings=embeddings) if embeddings else None","handlingStrategy":"validation","validationCode":"if not query_embeddings:\n    return []  # empty batch of queries is a no-op","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard batch-search loops for empty query lists","Unit-test the zero-query path as a no-op"],"tags":["validation","search","qdrant","edge-case"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}