{"record":{"id":"68f8d47e820c54bc","repo":"mem0ai/mem0","slug":"either-a-client-or-url-and-token-must-be-provided-68f8d4","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/configs/vector_stores/upstash_vector.py","lineNumber":31,"sourceCode":"    Index: ClassVar[type] = Index\n\n    url: Optional[str] = Field(None, description=\"URL for Upstash Vector index\")\n    token: Optional[str] = Field(None, description=\"Token for Upstash Vector index\")\n    client: Optional[Index] = Field(None, description=\"Existing `upstash_vector.Index` client instance\")\n    collection_name: str = Field(\"mem0\", description=\"Namespace to use for the index\")\n    enable_embeddings: bool = Field(\n        False, description=\"Whether to use built-in upstash embeddings or not. Default is True.\"\n    )\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def check_credentials_or_client(cls, values: Dict[str, Any]) -> Dict[str, Any]:\n        client = values.get(\"client\")\n        url = values.get(\"url\") or os.environ.get(\"UPSTASH_VECTOR_REST_URL\")\n        token = values.get(\"token\") or os.environ.get(\"UPSTASH_VECTOR_REST_TOKEN\")\n\n        if not client and not (url and token):\n            raise ValueError(\"Either a client or URL and token must be provided.\")\n\n        # Persist the env-resolved credentials so the provider constructor receives\n        # them; the validator used to check the env vars but drop them, so an\n        # env-var-only config passed validation and then raised on build.\n        if not client:\n            values[\"url\"] = url\n            values[\"token\"] = token\n        return values\n\n    model_config = ConfigDict(arbitrary_types_allowed=True)\n","sourceCodeStart":13,"sourceCodeEnd":42,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/configs/vector_stores/upstash_vector.py#L13-L42","documentation":"UpstashVectorConfig requires either an existing 'client' (an upstash_vector.Index instance) or both a URL and a token. The validator resolves url/token from the config first, then falls back to UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN env vars; if after that fallback either value (or both) is missing and no client was given, it raises. It also writes the env-resolved values back into the config so construction succeeds later.","triggerScenarios":"Passing url but not token (or vice versa); setting only one of the two env vars; passing client=None explicitly with no url/token; env vars set under different names (e.g. UPSTASH_VECTOR_URL).","commonSituations":"Copying only UPSTASH_VECTOR_REST_URL from the Upstash dashboard and forgetting the token; .env file not loaded before Memory(...) is constructed; assuming the REST URL alone is enough because the console shows it first.","solutions":["Set both UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN, or pass both url= and token= in the config","Or inject a pre-built client: config={'client': Index(url=..., token=...)}","If using .env, ensure it is loaded (python-dotenv) before instantiating Memory"],"exampleFix":"# before\nconfig = {\"url\": \"https://my-index.upstash.io\"}  # token missing\n\n# after\nconfig = {\"url\": \"https://my-index.upstash.io\", \"token\": \"UPSTASH_TOKEN\"}","handlingStrategy":"validation","validationCode":"import os\nurl = cfg.get(\"url\") or os.environ.get(\"UPSTASH_VECTOR_REST_URL\")\ntoken = cfg.get(\"token\") or os.environ.get(\"UPSTASH_VECTOR_REST_TOKEN\")\nif not cfg.get(\"client\") and not (url and token):\n    raise ConfigError(\"Upstash needs a client, or both url and token (values or env vars)\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set both UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN together in the same place","Load .env files before constructing Memory so env fallbacks resolve"],"tags":["upstash","vector-store","credentials","environment","validation"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}