{"record":{"id":"fc125715caa0c801","repo":"langgenius/dify","slug":"elasticsearch-password-is-required-for-self-hosted","errorCode":null,"errorMessage":"ELASTICSEARCH_PASSWORD is required for self-hosted Elasticsearch","messagePattern":"ELASTICSEARCH_PASSWORD is required for self-hosted Elasticsearch","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"api/configs/middleware/vdb/elasticsearch_config.py","lineNumber":72,"sourceCode":"    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":54,"sourceCodeEnd":75,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/configs/middleware/vdb/elasticsearch_config.py#L54-L75","documentation":"Raised by validate_elasticsearch_config (self-hosted branch) when ELASTICSEARCH_PASSWORD is empty. Default is 'elastic', so this fires only when the password is explicitly blanked.","triggerScenarios":"Setting ELASTICSEARCH_PASSWORD='' while using self-hosted ES.","commonSituations":"Operator clears the default password but never sets a real one, or secrets injection fails to populate the var.","solutions":["Set ELASTICSEARCH_PASSWORD to the cluster credential.","Inject the password via a secrets manager / docker secret rather than clearing it.","Restore the default if running a dev cluster with the stock password."],"exampleFix":"// before\nELASTICSEARCH_PASSWORD=\n// after\nELASTICSEARCH_PASSWORD=<strong-password>","handlingStrategy":"validation","validationCode":"def es_password_present(use_cloud: bool, password: str | None) -> bool:\n    return use_cloud or bool(password)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inject ELASTICSEARCH_PASSWORD via a secret, never blank it.","Rotate the default 'elastic' password in any non-dev cluster.","Pre-flight check that secrets populate before app boot."],"tags":["config","pydantic","elasticsearch","vdb","security","required-field"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}