{"record":{"id":"5fe3cd8594e882d0","repo":"mem0ai/mem0","slug":"vector-with-id-vector-id-not-found","errorCode":null,"errorMessage":"Vector with ID {vector_id} not found","messagePattern":"Vector with ID (.+?) not found","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/databricks.py","lineNumber":700,"sourceCode":"                \"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                query_kwargs[\"query_text\"] = \" \"\n            else:\n                query_kwargs[\"query_vector\"] = [0.0] * self.embedding_dimension\n\n            results = self.client.vector_search_indexes.query_index(**query_kwargs)\n\n            # Process results\n            result_data = results.result if hasattr(results, \"result\") else results\n            data_array = result_data.data_array if hasattr(result_data, \"data_array\") else []\n\n            if not data_array:\n                raise KeyError(f\"Vector with ID {vector_id} not found\")\n\n            result = data_array[0]\n            columns = [col.name for col in results.manifest.columns] if results.manifest and results.manifest.columns else []\n            row_data = dict(zip(columns, result))\n\n            # Build payload following the standard schema\n            payload = {\n                \"hash\": row_data.get(\"hash\", \"unknown\"),\n                \"data\": row_data.get(\"memory\", row_data.get(\"data\", \"unknown\")),\n                \"created_at\": row_data.get(\"created_at\"),\n            }\n\n            # Add updated_at if available\n            if \"updated_at\" in row_data:\n                payload[\"updated_at\"] = row_data.get(\"updated_at\")\n\n            # Add optional fields\n            for field in [\"agent_id\", \"run_id\", \"user_id\"]:","sourceCodeStart":682,"sourceCodeEnd":718,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/databricks.py#L682-L718","documentation":"KeyError raised in Databricks get(vector_id): the store works around the lack of a direct get API by running an internal index query (query_text=' ' or a zero vector) and filtering, and if that returns an empty data_array it raises KeyError to mimic not-found semantics of other mem0 stores.","triggerScenarios":"Calling get() with a memory_id that was deleted or never inserted; a stale ID kept in application state after delete_all(); the workaround query legitimately returning zero rows because the ID column value does not match (e.g. type or quoting differences).","commonSituations":"UI showing cached history entries after memories were removed; retry logic referencing an ID from a previous environment/index; ID normalization differences between insert and lookup.","solutions":["Catch KeyError and treat it as 'memory not found' (delete/skip/refresh local state).","Verify the ID exists via list/get_all before acting on cached references.","After delete_all or environment switches, invalidate any locally cached memory IDs."],"exampleFix":"# before\nmem = store.get(memory_id)  # KeyError bubbles up\n\n# after\ntry:\n    mem = store.get(memory_id)\nexcept KeyError:\n    logger.info(\"memory %s no longer exists\", memory_id)\n    mem = None","handlingStrategy":"try-catch","validationCode":"def get_or_none(store, memory_id: str):\n    try:\n        return store.get(memory_id)\n    except KeyError:\n        return None","typeGuard":null,"tryCatchPattern":"try:\n    memory = store.get(memory_id)\nexcept KeyError:\n    logger.info(\"memory %s not found (deleted or stale id)\", memory_id)\n    memory = None\n# proceed with memory possibly None","preventionTips":["Treat KeyError from get() as the documented not-found signal for this store.","Invalidate cached memory IDs after delete/delete_all and across environment resets.","Return 404 from your API layer when get_or_none comes back None instead of crashing."],"tags":["databricks","get","not-found","key-error"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}