{"record":{"id":"85cff79bda7a4646","repo":"mem0ai/mem0","slug":"must-provide-vectors-for-search","errorCode":null,"errorMessage":"Must provide vectors for search.","messagePattern":"Must provide vectors for search\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/databricks.py","lineNumber":499,"sourceCode":"            # - query_vector: for Direct Access Index and Delta Sync Index with self-managed vectors\n            query_kwargs = {\n                \"index_name\": self.fully_qualified_index_name,\n                \"columns\": self.column_names,\n                \"num_results\": top_k,\n                \"query_type\": self.query_type,\n                \"filters_json\": filters_json,\n            }\n            uses_model_endpoint = (\n                self.index_type == VectorIndexType.DELTA_SYNC and self.embedding_model_endpoint_name\n            )\n            if uses_model_endpoint:\n                if not query:\n                    raise ValueError(\"Query text is required for Delta Sync Index with model endpoint.\")\n                query_kwargs[\"query_text\"] = query\n            elif vectors:\n                query_kwargs[\"query_vector\"] = vectors\n            else:\n                raise ValueError(\"Must provide vectors for search.\")\n\n            sdk_results = self.client.vector_search_indexes.query_index(**query_kwargs)\n\n            # Parse results\n            result_data = sdk_results.result if hasattr(sdk_results, \"result\") else sdk_results\n            data_array = result_data.data_array if getattr(result_data, \"data_array\", None) else []\n\n            memory_results = []\n            for row in data_array:\n                # Map columns to values\n                row_dict = dict(zip(self.column_names, row)) if isinstance(row, (list, tuple)) else row\n                score = row_dict.get(\"score\") or (\n                    row[-1] if isinstance(row, (list, tuple)) and len(row) > len(self.column_names) else None\n                )\n                payload = {k: row_dict.get(k) for k in self.column_names}\n                payload[\"data\"] = payload.get(\"memory\", \"\")\n                memory_id = row_dict.get(\"memory_id\") or row_dict.get(\"id\")\n                memory_results.append(MemoryResult(id=memory_id, score=score, payload=payload))","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/databricks.py#L481-L517","documentation":"ValueError raised in Databricks search when the store does NOT use a model endpoint and the caller supplied neither a usable query path nor vectors. In the elif branch, a falsy/empty vectors argument (None or []) means there is nothing to search with — the index requires a query_vector for nearest-neighbor lookup.","triggerScenarios":"Calling search(query=..., vectors=None) on a DIRECT_ACCESS index, or search(vectors=[]) after an embedding call returned an empty list (e.g. embedding failure swallowed upstream).","commonSituations":"Embedding client returning None/[] on error and the value passed straight through; search invoked before embeddings are ready; default parameter vectors=None hit when caller only had text but store expects vectors.","solutions":["Compute the query embedding first and pass it: store.search(query=text, vectors=embedder.embed(text), top_k=5).","Check the embedding result for None/empty before searching; treat an empty embedding as an upstream error.","If you have no local embedder, configure embedding_model_endpoint_name on the store so text-only search works."],"exampleFix":"# before\nstore.search(query=\"hello\", vectors=None, top_k=5)  # ValueError\n\n# after\nvec = embedder.embed(\"hello\")\nif not vec:\n    raise RuntimeError(\"embedding failed\")\nstore.search(query=\"hello\", vectors=vec, top_k=5)","handlingStrategy":"validation","validationCode":"def require_query_vector(vectors) -> list:\n    if not vectors or not isinstance(vectors, (list, tuple)) or not isinstance(vectors[0], (int, float)):\n        raise ValueError(\"a non-empty numeric query vector is required\")\n    return list(vectors)\n\nvec = embedder.embed(query_text)\nif not vec:\n    raise RuntimeError(\"embedding produced no vector; check embedding provider\")\nresults = store.search(query=query_text, vectors=vec, top_k=5)","typeGuard":"def is_valid_query_vector(v) -> bool:\n    return isinstance(v, (list, tuple)) and len(v) > 0 and all(isinstance(x, (int, float)) for x in v)","tryCatchPattern":null,"preventionTips":["Treat an empty/None embedding as an upstream error; never pass it to search.","Wrap embed+search in one function so vectors and query cannot get out of sync.","If you only ever search by text, configure a model endpoint so text-only search is valid."],"tags":["databricks","search","validation","embeddings"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}