{"record":{"id":"98106e3938cf7a5f","repo":"mem0ai/mem0","slug":"either-a-client-or-url-and-token-must-be-provided-98106e","errorCode":null,"errorMessage":"Either a client or URL and token must be provided.","messagePattern":"Either a client or URL and token must be provided\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/upstash_vector.py","lineNumber":64,"sourceCode":"        token: Optional[str] = None,\n        client: Optional[Index] = None,\n        enable_embeddings: bool = False,\n    ):\n        \"\"\"\n        Initialize the UpstashVector vector store.\n\n        Args:\n            url (str, optional): URL for Upstash Vector index. Defaults to None.\n            token (int, optional): Token for Upstash Vector index. Defaults to None.\n            client (Index, optional): Existing `upstash_vector.Index` client instance. Defaults to None.\n            namespace (str, optional): Default namespace for the index. Defaults to None.\n        \"\"\"\n        if client:\n            self.client = client\n        elif url and token:\n            self.client = Index(url, token)\n        else:\n            raise ValueError(\"Either a client or URL and token must be provided.\")\n\n        self.collection_name = collection_name\n\n        self.enable_embeddings = enable_embeddings\n\n    def insert(\n        self,\n        vectors: List[list],\n        payloads: Optional[List[Dict]] = None,\n        ids: Optional[List[str]] = None,\n    ):\n        \"\"\"\n        Insert vectors\n\n        Args:\n            vectors (list): List of vectors to insert.\n            payloads (list, optional): List of payloads corresponding to vectors. These will be passed as metadatas to the Upstash Vector client. Defaults to None.\n            ids (list, optional): List of IDs corresponding to vectors. Defaults to None.","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/upstash_vector.py#L46-L82","documentation":"Raised in UpstashVector.__init__ when the constructor gets neither an injected `client` nor both `url` and `token`. The branching is strict: only `url and token` together form a valid Index; passing just one of them (or neither) lands in the else. Unlike some stores there is no environment-variable fallback in this module — credentials must come from config or an injected client.","triggerScenarios":"`UpstashVector(collection_name=\"mem\")` with no url/token/client; config with `\"token\": ...` but a missing or misnamed `\"url\"` key; passing url but relying on an env var for the token that this class never reads.","commonSituations":"Assuming UPSTASH_VECTOR_REST_URL/TOKEN env vars are picked up automatically (the hosted platform does that, this OSS store may not, depending on config wiring); typos in config keys; partially redacted config templates.","solutions":["Supply both credentials in the vector store config: `\"config\": {\"url\": ..., \"token\": ..., \"collection_name\": \"mem\"}`.","Or build the client yourself and pass `client=Index(url, token)`.","If using env vars, wire them explicitly: `\"url\": os.environ[\"UPSTASH_VECTOR_REST_URL\"]`."],"exampleFix":"# before\nmemory = Memory.from_config({\n    \"vector_store\": {\"provider\": \"upstash_vector\", \"config\": {\"collection_name\": \"mem\"}}\n})  # ValueError\n\n# after\nimport os\nmemory = Memory.from_config({\n    \"vector_store\": {\n        \"provider\": \"upstash_vector\",\n        \"config\": {\n            \"collection_name\": \"mem\",\n            \"url\": os.environ[\"UPSTASH_VECTOR_REST_URL\"],\n            \"token\": os.environ[\"UPSTASH_VECTOR_REST_TOKEN\"],\n        },\n    }\n})","handlingStrategy":"validation","validationCode":"import os\n\ndef upstash_config() -> dict:\n    url = os.environ.get(\"UPSTASH_VECTOR_REST_URL\")\n    token = os.environ.get(\"UPSTASH_VECTOR_REST_TOKEN\")\n    if not (url and token):\n        raise SystemExit(\"Upstash Vector requires both UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN\")\n    return {\"provider\": \"upstash_vector\", \"config\": {\"url\": url, \"token\": token, \"collection_name\": \"mem\"}}","typeGuard":null,"tryCatchPattern":"try:\n    store = UpstashVector(collection_name=\"mem\", url=url, token=token)\nexcept ValueError as e:\n    if \"client or URL and token\" in str(e):\n        raise RuntimeError(\"Upstash credentials incomplete: need both url and token\") from e\n    raise","preventionTips":["Provide url and token as a pair in config, or inject a pre-built Index client.","Do not assume env-var fallbacks exist for this store — wire credentials explicitly.","Validate credential presence in a boot-time preflight for every configured provider."],"tags":["configuration","upstash","credentials","vector-store"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}