{"record":{"id":"ca3d354b14b030f9","repo":"mem0ai/mem0","slug":"either-cloud-id-or-host-must-be-provided","errorCode":null,"errorMessage":"Either cloud_id or host must be provided","messagePattern":"Either cloud_id or host must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/configs/vector_stores/elasticsearch.py","lineNumber":30,"sourceCode":"    password: Optional[str] = Field(None, description=\"Password for authentication\")\n    cloud_id: Optional[str] = Field(None, description=\"Cloud ID for Elastic Cloud\")\n    api_key: Optional[str] = Field(None, description=\"API key for authentication\")\n    embedding_model_dims: int = Field(1536, description=\"Dimension of the embedding vector\")\n    verify_certs: bool = Field(True, description=\"Verify SSL certificates\")\n    ca_certs: Optional[str] = Field(None, description=\"Path to CA bundle for SSL certificate verification\")\n    use_ssl: bool = Field(True, description=\"Use SSL for connection\")\n    auto_create_index: bool = Field(True, description=\"Automatically create index during initialization\")\n    custom_search_query: Optional[Callable[[List[float], int, Optional[Dict]], Dict]] = Field(\n        None, description=\"Custom search query function. Parameters: (query, top_k, filters) -> Dict\"\n    )\n    headers: Optional[Dict[str, str]] = Field(None, description=\"Custom headers to include in requests\")\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def validate_auth(cls, values: Dict[str, Any]) -> Dict[str, Any]:\n        # Check if either cloud_id or host/port is provided\n        if not values.get(\"cloud_id\") and not values.get(\"host\"):\n            raise ValueError(\"Either cloud_id or host must be provided\")\n\n        # Check if authentication is provided\n        if not any([values.get(\"api_key\"), (values.get(\"user\") and values.get(\"password\"))]):\n            raise ValueError(\"Either api_key or user/password must be provided\")\n\n        return values\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def validate_headers(cls, values: Dict[str, Any]) -> Dict[str, Any]:\n        \"\"\"Validate headers format and content\"\"\"\n        headers = values.get(\"headers\")\n        if headers is not None:\n            # Check if headers is a dictionary\n            if not isinstance(headers, dict):\n                raise ValueError(\"headers must be a dictionary\")\n            \n            # Check if all keys and values are strings","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/configs/vector_stores/elasticsearch.py#L12-L48","documentation":"Raised by the Elasticsearch vector store config's auth validator when neither cloud_id nor host is supplied. Mem0's ES client needs either an Elastic Cloud deployment id or a direct host to connect to; without either there is no endpoint, so validation aborts before any network activity.","triggerScenarios":"Creating ElasticsearchConfig with neither 'cloud_id' nor 'host' key (or both None/empty). Note the check is purely on cloud_id and host — port, user, password, api_key alone will not satisfy it.","commonSituations":"Expecting ELASTICSEARCH_URL env pickup (not implemented); cloud_id living in a .env file that was not loaded; host key typo'd as 'hostname' or 'url'; config built conditionally where the endpoint branch never executes.","solutions":["Set 'cloud_id' to your Elastic Cloud deployment's cloud id","Or set 'host' (e.g. 'http://localhost:9200' or 'https://cluster.example.com:9200')","Verify the env/file source that populates the endpoint actually loads before config construction","Check key spelling against the model fields if you believe the endpoint is set"],"exampleFix":"# before\nElasticsearchConfig(api_key=\"k\")\n\n# after\nElasticsearchConfig(host=\"http://localhost:9200\", api_key=\"k\")","handlingStrategy":"validation","validationCode":"def validate_es_endpoint(cfg: dict) -> None:\n    if not cfg.get(\"cloud_id\") and not cfg.get(\"host\"):\n        raise RuntimeError(\"Elasticsearch config needs 'cloud_id' or 'host'\")","typeGuard":"def has_es_endpoint(cfg: dict) -> bool:\n    return bool(cfg.get(\"cloud_id\") or cfg.get(\"host\"))","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    ElasticsearchConfig(**cfg)\nexcept ValidationError as e:\n    if \"cloud_id or host\" in str(e):\n        # set the endpoint from env/deployment metadata, then retry\n        ...","preventionTips":["Load .env before building config; env vars are not read implicitly","Assert the endpoint key exists in a startup check","Watch for key typos (hostname/url) that bypass the check"],"tags":["pydantic","configuration","vector-store","elasticsearch","connection"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}