{"record":{"id":"c51807087b67b193","repo":"mem0ai/mem0","slug":"query-text-is-required-for-delta-sync-index-with-m","errorCode":null,"errorMessage":"Query text is required for Delta Sync Index with model endpoint.","messagePattern":"Query text is required for Delta Sync Index with model endpoint\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/databricks.py","lineNumber":494,"sourceCode":"        try:\n            filters_json = json.dumps(filters) if filters else None\n\n            # Choose query mode per Databricks SDK contract:\n            # - query_text: for Delta Sync Index with model endpoint\n            # - 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","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/databricks.py#L476-L512","documentation":"ValueError raised in Databricks search when the store is a DELTA_SYNC index with an embedding_model_endpoint_name configured (so Databricks does the embedding server-side) but the caller passed an empty/None query string. The endpoint needs the raw text to embed; without it the query cannot be formed, and vectors are NOT accepted as an alternative in this branch.","triggerScenarios":"Calling search(query='', vectors=[...], top_k=...) or search(query=None, ...) on a DELTA_SYNC + model-endpoint setup. The check uses truthiness, so even whitespace-only handling matters only insofar as '' and None are falsy.","commonSituations":"Pipeline code written for a DIRECT_ACCESS store passing only vectors; user-supplied empty search strings not filtered upstream; search invoked programmatically with a default query=None.","solutions":["Pass a non-empty query string; with a model endpoint the text is embedded by Databricks, so it is mandatory.","Validate/reject empty queries in your own layer before calling search.","If you want to search by precomputed vectors instead, remove embedding_model_endpoint_name (use DIRECT_ACCESS semantics) so the vectors branch is taken."],"exampleFix":"# before\nstore.search(query=\"\", vectors=emb, top_k=5)  # ValueError on DELTA_SYNC+endpoint\n\n# after\nstore.search(query=user_text, top_k=5)  # endpoint embeds the text","handlingStrategy":"validation","validationCode":"def require_query_text(query: str) -> str:\n    if not isinstance(query, str) or not query.strip():\n        raise ValueError(\"non-empty query text is required for model-endpoint search\")\n    return query\n\nresults = store.search(query=require_query_text(user_query), top_k=5)","typeGuard":"def has_nonempty_query(q) -> bool:\n    return isinstance(q, str) and len(q.strip()) > 0","tryCatchPattern":null,"preventionTips":["Reject empty search strings at the API/service layer with a user-friendly message.","Encapsulate store.search in one repository method that knows whether the store expects text or vectors.","Document which embedding mode (endpoint vs client) your store was built with."],"tags":["databricks","search","validation"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}