{"record":{"id":"9124f142d83be042","repo":"mem0ai/mem0","slug":"the-upstash-vector-library-is-required-please-i-9124f1","errorCode":null,"errorMessage":"The 'upstash_vector' library is required. Please install it using 'pip install upstash_vector'.","messagePattern":"The 'upstash_vector' library is required\\. Please install it using 'pip install upstash_vector'\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/upstash_vector.py","lineNumber":12,"sourceCode":"import logging\nimport re\nfrom typing import Any, Dict, List, Optional\n\nfrom pydantic import BaseModel\n\nfrom mem0.vector_stores.base import VectorStoreBase\n\ntry:\n    from upstash_vector import Index\nexcept ImportError:\n    raise ImportError(\"The 'upstash_vector' library is required. Please install it using 'pip install upstash_vector'.\")\n\n\nlogger = logging.getLogger(__name__)\n\n_SAFE_FILTER_KEY = re.compile(r\"[a-zA-Z_][a-zA-Z0-9_]*\\Z\")\n\n\ndef _validate_filter(key: str, value: Any) -> None:\n    if not isinstance(key, str) or not _SAFE_FILTER_KEY.fullmatch(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, \"\n            f\"got {type(value).__name__}\"\n        )\n    if isinstance(value, str) and ('\"' in value or \"\\\\\" in value):\n        raise ValueError(\n            f\"Filter value for {key!r} contains prohibited characters \"","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/upstash_vector.py#L1-L30","documentation":"Raised at import time when the `upstash_vector` package is missing. mem0's Upstash Vector store wraps that SDK's Index client, and like all provider SDKs it is optional, so the module raises ImportError with the exact pip command rather than failing later at runtime.","triggerScenarios":"`from mem0.vector_stores.upstash_vector import UpstashVector` or `\"vector_store\": {\"provider\": \"upstash_vector\"}` where `from upstash_vector import Index` fails.","commonSituations":"Package name confusion — the correct PyPI name uses an underscore (`upstash_vector`), while Upstash docs sometimes show `@upstash/vector` for JS; base mem0ai installs; serverless deployments that prune dependencies aggressively.","solutions":["Install with the exact name shown: `pip install upstash_vector`.","Ensure UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN (or explicit url/token config) are also available, since the next failure after import is missing credentials.","Verify the interpreter/environment if the import still fails post-install."],"exampleFix":"# before\nfrom mem0.vector_stores.upstash_vector import UpstashVector  # ImportError\n\n# after\n# pip install upstash_vector\nfrom mem0.vector_stores.upstash_vector import UpstashVector  # ok","handlingStrategy":"try-catch","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"upstash_vector\") is None:\n    raise SystemExit(\"Missing dependency: upstash_vector. Run: pip install upstash_vector\")","typeGuard":null,"tryCatchPattern":"try:\n    from mem0.vector_stores.upstash_vector import UpstashVector\nexcept ImportError as e:\n    raise RuntimeError(f\"Upstash Vector SDK missing: {e}. Install with pip install upstash_vector.\") from e","preventionTips":["The PyPI name is underscored — `upstash_vector`, not `upstash` and not the npm package.","Install URL and token configuration together with the package so the next failure is not credentials.","Smoke-test provider imports in CI for every provider referenced by your config."],"tags":["dependencies","upstash","import-error","installation","vector-store"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}