{"record":{"id":"84741dae68f9a1fa","repo":"run-llama/llama_index","slug":"vector-store-query-result-should-return-at-least-o","errorCode":null,"errorMessage":"Vector store query result should return at least one of nodes or ids.","messagePattern":"Vector store query result should return at least one of nodes or ids\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/indices/document_summary/retrievers.py","lineNumber":182,"sourceCode":"                query_bundle.embedding = (\n                    self._embed_model.get_agg_embedding_from_queries(\n                        query_bundle.embedding_strs\n                    )\n                )\n\n        query = VectorStoreQuery(\n            query_embedding=query_bundle.embedding,\n            similarity_top_k=self._similarity_top_k,\n        )\n        query_result = self._vector_store.query(query)\n\n        top_k_summary_ids: List[str]\n        if query_result.ids is not None:\n            top_k_summary_ids = query_result.ids\n        elif query_result.nodes is not None:\n            top_k_summary_ids = [n.node_id for n in query_result.nodes]\n        else:\n            raise ValueError(\n                \"Vector store query result should return at least one of nodes or ids.\"\n            )\n\n        results = []\n        for summary_id in top_k_summary_ids:\n            node_ids = self._index_struct.summary_id_to_node_ids[summary_id]\n            nodes = self._docstore.get_nodes(node_ids)\n            results.extend([NodeWithScore(node=n) for n in nodes])\n        return results\n\n\n# legacy, backward compatibility\nDocumentSummaryIndexRetriever = DocumentSummaryIndexLLMRetriever\n","sourceCodeStart":164,"sourceCodeEnd":196,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/indices/document_summary/retrievers.py#L164-L196","documentation":"DocumentSummaryIndexEmbeddingRetriever converts a vector store query result into summary ids using either query_result.ids or query_result.nodes. A conforming VectorStoreQueryResult must populate at least one; if both are None the retriever has nothing to map back to summaries and raises ValueError. This almost always indicates a custom or misbehaving vector store implementation rather than bad caller input.","triggerScenarios":"Using DocumentSummaryIndex(..., embed_summaries=True) with a custom VectorStore whose query() returns VectorStoreQueryResult(nodes=None, ids=None); a store wrapper that drops ids; an in-memory/simple store whose query is not fully implemented.","commonSituations":"Plugging in a custom or third-party vector store that returns only similarities or an empty result object; adapters that build VectorStoreQueryResult without copying ids from the backend response; empty-result edge cases where the store returns a bare result.","solutions":["Fix the custom vector store's query() to always set ids (and ideally nodes) on VectorStoreQueryResult before returning it.","Test the store in isolation: res = store.query(VectorStoreQuery(query_embedding=emb, similarity_top_k=5)); assert res.ids or res.nodes.","Switch to a battle-tested store (Chroma, Qdrant, FAISS, Postgres) to confirm the issue is store-specific.","Return empty lists rather than None fields on zero hits so the retriever degrades gracefully."],"exampleFix":"# before (custom store)\ndef query(self, q, **kwargs):\n    sims, ids = self._search(q.query_embedding, q.similarity_top_k)\n    return VectorStoreQueryResult(similarities=sims)  # ids/nodes None -> ValueError downstream\n\n# after\ndef query(self, q, **kwargs):\n    sims, ids = self._search(q.query_embedding, q.similarity_top_k)\n    return VectorStoreQueryResult(similarities=sims, ids=ids or [])","handlingStrategy":"try-catch","validationCode":"res = vector_store.query(VectorStoreQuery(query_embedding=emb, similarity_top_k=2))\nassert res.ids is not None or res.nodes is not None, \"store returns empty result objects\"","typeGuard":null,"tryCatchPattern":"try:\n    results = retriever.retrieve(query_str)\nexcept ValueError as e:\n    if \"nodes or ids\" in str(e):\n        # vector store contract violation; log store type and retry with a known-good store\n        logger.error(\"vector store %s violates query-result contract\", type(vector_store).__name__)\n        raise\n    raise","preventionTips":["Write a contract test for any custom vector store: query() must populate ids or nodes on VectorStoreQueryResult.","Return empty lists instead of None for ids/nodes on zero-hit queries."],"tags":["document-summary-index","vector-store","retriever","custom-store"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}