{"record":{"id":"41ab46bc301d7c6f","repo":"langgenius/dify","slug":"elasticsearch-cloud-url-is-required-when-using-ela","errorCode":null,"errorMessage":"ELASTICSEARCH_CLOUD_URL is required when using Elastic Cloud","messagePattern":"ELASTICSEARCH_CLOUD_URL is required when using Elastic Cloud","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"api/configs/middleware/vdb/elasticsearch_config.py","lineNumber":63,"sourceCode":"    ELASTICSEARCH_VERIFY_CERTS: bool = Field(\n        description=\"Whether to verify SSL certificates (default is False)\", default=False\n    )\n    ELASTICSEARCH_REQUEST_TIMEOUT: int = Field(\n        description=\"Request timeout in milliseconds (default is 100000)\", default=100000\n    )\n    ELASTICSEARCH_RETRY_ON_TIMEOUT: bool = Field(\n        description=\"Whether to retry requests on timeout (default is True)\", default=True\n    )\n    ELASTICSEARCH_MAX_RETRIES: int = Field(\n        description=\"Maximum number of retry attempts (default is 10000)\", default=10000\n    )\n\n    @model_validator(mode=\"after\")\n    def validate_elasticsearch_config(self):\n        \"\"\"Validate Elasticsearch configuration based on deployment type.\"\"\"\n        if self.ELASTICSEARCH_USE_CLOUD:\n            if not self.ELASTICSEARCH_CLOUD_URL:\n                raise ValueError(\"ELASTICSEARCH_CLOUD_URL is required when using Elastic Cloud\")\n            if not self.ELASTICSEARCH_API_KEY:\n                raise ValueError(\"ELASTICSEARCH_API_KEY is required when using Elastic Cloud\")\n        else:\n            if not self.ELASTICSEARCH_HOST:\n                raise ValueError(\"ELASTICSEARCH_HOST is required for self-hosted Elasticsearch\")\n            if not self.ELASTICSEARCH_USERNAME:\n                raise ValueError(\"ELASTICSEARCH_USERNAME is required for self-hosted Elasticsearch\")\n            if not self.ELASTICSEARCH_PASSWORD:\n                raise ValueError(\"ELASTICSEARCH_PASSWORD is required for self-hosted Elasticsearch\")\n\n        return self\n","sourceCodeStart":45,"sourceCodeEnd":75,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/configs/middleware/vdb/elasticsearch_config.py#L45-L75","documentation":"Raised by ElasticsearchConfig.validate_elasticsearch_config when ELASTICSEARCH_USE_CLOUD is true but ELASTICSEARCH_CLOUD_URL is empty. Elastic Cloud deployments are addressed by their dedicated endpoint URL rather than host/port.","triggerScenarios":"Setting ELASTICSEARCH_USE_CLOUD=true without ELASTICSEARCH_CLOUD_URL (while selecting elasticsearch as VECTOR_STORE).","commonSituations":"Switching from self-hosted ES to Elastic Cloud and forgetting the cloud URL, or setting the boolean via one env and the URL via another.","solutions":["Set ELASTICSEARCH_CLOUD_URL to the Elastic Cloud deployment URL (e.g. 'https://xxx.es.region.aws.found.io:443').","Set ELASTICSEARCH_API_KEY as well (the next guard requires it).","If self-hosted, set ELASTICSEARCH_USE_CLOUD=false (default)."],"exampleFix":"// before\nELASTICSEARCH_USE_CLOUD=true\n// after\nELASTICSEARCH_USE_CLOUD=true\nELASTICSEARCH_CLOUD_URL=https://xxx.es.region.aws.found.io:443\nELASTICSEARCH_API_KEY=<key>","handlingStrategy":"validation","validationCode":"def es_cloud_ok(use_cloud: bool, cloud_url: str | None, api_key: str | None) -> bool:\n    return (not use_cloud) or bool(cloud_url and api_key)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When enabling ELASTICSEARCH_USE_CLOUD, set both cloud URL and API key.","Keep cloud credentials in a single env file.","Pre-flight check the cloud endpoint reachable before boot."],"tags":["config","pydantic","elasticsearch","vdb","required-field"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}