{"record":{"id":"050f9a224c53165d","repo":"mem0ai/mem0","slug":"opensearch-requires-extra-dependencies-install-wi","errorCode":null,"errorMessage":"OpenSearch requires extra dependencies. Install with `pip install opensearch-py`","messagePattern":"OpenSearch requires extra dependencies\\. Install with `pip install opensearch-py`","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"mem0/vector_stores/opensearch.py","lineNumber":9,"sourceCode":"import logging\nimport re\nimport time\nfrom typing import Any, Dict, List, Optional\n\ntry:\n    from opensearchpy import OpenSearch, RequestsHttpConnection\nexcept ImportError:\n    raise ImportError(\"OpenSearch requires extra dependencies. Install with `pip install opensearch-py`\") from None\n\nfrom pydantic import BaseModel\n\nfrom mem0.configs.vector_stores.opensearch import OpenSearchConfig\nfrom mem0.vector_stores.base import VectorStoreBase\n\nlogger = logging.getLogger(__name__)\n\n_SAFE_FILTER_KEY = re.compile(r\"^[a-zA-Z_][a-zA-Z0-9_.]*$\")\n_IDENTITY_FILTER_KEYS = (\"user_id\", \"agent_id\", \"run_id\")\n\n\ndef _validate_filter(key: str, value) -> None:\n    if not isinstance(key, str) or not _SAFE_FILTER_KEY.match(key):\n        raise ValueError(f\"Invalid filter key: {key!r}\")\n    if not isinstance(value, (str, int, float, bool)):\n        raise ValueError(\n            f\"Filter value for {key!r} must be str, int, float, or bool, \"","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/opensearch.py#L1-L27","documentation":"Import-time ImportError from the OpenSearch vector store: the module needs the opensearch-py package (classes OpenSearch and RequestsHttpConnection). If it is absent, the guard fires as soon as the module is imported — i.e. as soon as the config selects the opensearch provider — before any connection attempt.","triggerScenarios":"Configuring vector_store.provider=\"opensearch\" without pip install opensearch-py; environments where elasticsearch (different package) was installed instead; CI base images missing the vector-store extras.","commonSituations":"Installing mem0ai without extras then pointing config at OpenSearch; name confusion between opensearch-py and elasticsearch-py; slim Docker images that strip optional deps.","solutions":["pip install opensearch-py","If you installed elasticsearch by mistake, either add opensearch-py or switch provider to elasticsearch","Pin opensearch-py in the deploy requirements so image builds include it"],"exampleFix":"# before\npip install mem0ai\n# provider \"opensearch\" -> ImportError\n\n# after\npip install mem0ai opensearch-py","handlingStrategy":"validation","validationCode":"try:\n    import opensearchpy  # noqa\nexcept ImportError:\n    raise SystemExit(\"opensearch-py required: pip install opensearch-py\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install opensearch-py in the base image when the provider is opensearch","CI smoke test: import the module for the configured provider","Do not substitute elasticsearch-py; it is a different provider"],"tags":["opensearch","import-error","dependencies","vector-store"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}