{"record":{"id":"8b9b847c9252db34","repo":"mem0ai/mem0","slug":"cannot-specify-both-cloud-configuration-and-local","errorCode":null,"errorMessage":"Cannot specify both cloud configuration and local configuration. Choose one.","messagePattern":"Cannot specify both cloud configuration and local configuration\\. Choose one\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/configs/vector_stores/chroma.py","lineNumber":42,"sourceCode":"        host, port, path = values.get(\"host\"), values.get(\"port\"), values.get(\"path\")\n        api_key, tenant = values.get(\"api_key\"), values.get(\"tenant\")\n        \n        # Check if cloud configuration is provided\n        cloud_config = bool(api_key and tenant)\n        \n        # If cloud configuration is provided, remove any default path that might have been added\n        if cloud_config and path == \"/tmp/chroma\":\n            values.pop(\"path\", None)\n            return values\n        \n        # Check if local/server configuration is provided\n        local_config = bool(path) or bool(host and port)\n        \n        if not cloud_config and not local_config:\n            raise ValueError(\"Either ChromaDB Cloud configuration (api_key, tenant) or local configuration (path or host/port) must be provided.\")\n        \n        if cloud_config and local_config:\n            raise ValueError(\"Cannot specify both cloud configuration and local configuration. Choose one.\")\n            \n        return values\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:\n        allowed_fields = set(cls.model_fields.keys())\n        input_fields = set(values.keys())\n        extra_fields = input_fields - allowed_fields\n        if extra_fields:\n            raise ValueError(\n                f\"Extra fields not allowed: {', '.join(extra_fields)}. Please input only the following fields: {', '.join(allowed_fields)}\"\n            )\n        return values\n\n    model_config = ConfigDict(arbitrary_types_allowed=True)\n","sourceCodeStart":24,"sourceCodeEnd":59,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/configs/vector_stores/chroma.py#L24-L59","documentation":"Raised by ChromaDbConfig when the same config enables both Chroma Cloud and a local/server connection. Cloud is detected as api_key+tenant both present; local as path or host+port. The client cannot be constructed for two backends at once, so the validator forces an explicit choice.","triggerScenarios":"Passing api_key and tenant alongside path, or alongside host and port. Subtle case: a default path ('/tmp/chroma') is auto-removed when cloud config exists, but any other path value still triggers the conflict.","commonSituations":"Migrating from local Chroma to cloud by adding api_key/tenant while leaving the old path in the config; a shared base config dict (with path) merged with cloud credentials; environment-specific overrides layering both modes.","solutions":["Delete path/host/port from the config and keep api_key+tenant for cloud-only","Or delete api_key/tenant and keep path (or host+port) for local-only","Audit merged/composed config dicts for stale local keys before adding cloud credentials","Use separate named configs per environment instead of mutating one shared dict"],"exampleFix":"# before\nChromaDbConfig(api_key=\"ck_...\", tenant=\"t\", path=\"./chroma_db\")\n\n# after\nChromaDbConfig(api_key=\"ck_...\", tenant=\"t\")","handlingStrategy":"validation","validationCode":"def validate_chroma_single_mode(cfg: dict) -> None:\n    cloud = bool(cfg.get(\"api_key\") and cfg.get(\"tenant\"))\n    local = bool(cfg.get(\"path\")) or bool(cfg.get(\"host\") and cfg.get(\"port\"))\n    if cloud and local:\n        raise RuntimeError(\"Choose ONE: Chroma cloud (api_key+tenant) or local (path / host+port)\")","typeGuard":"def chroma_single_mode(cfg: dict) -> bool:\n    cloud = bool(cfg.get(\"api_key\") and cfg.get(\"tenant\"))\n    local = bool(cfg.get(\"path\")) or bool(cfg.get(\"host\") and cfg.get(\"port\"))\n    return cloud != local","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    ChromaDbConfig(**cfg)\nexcept ValidationError as e:\n    if \"Cannot specify both\" in str(e):\n        # drop local keys (cloud wins) or drop cloud keys, then retry\n        ...","preventionTips":["When migrating local to cloud, delete path/host/port in the same change","Never merge a shared base config with cloud credentials blindly","Use environment-specific config files rather than layered overrides"],"tags":["pydantic","configuration","vector-store","chroma","conflicting-config"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}