{"record":{"id":"1c4d1652581c50f8","repo":"risingwavelabs/risingwave","slug":"please-set-the-username-when-the-password-is-set","errorCode":null,"errorMessage":"please set the username when the password is set.","messagePattern":"please set the username when the password is set\\.","errorType":"validation","errorClass":"SinkError","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/elasticsearch_opensearch/elasticsearch_opensearch_config.rs","lineNumber":198,"sourceCode":"\nimpl ElasticSearchOpenSearchConfig {\n    pub fn from_btreemap(properties: BTreeMap<String, String>) -> Result<Self> {\n        let config = serde_json::from_value::<ElasticSearchOpenSearchConfig>(\n            serde_json::to_value(properties).unwrap(),\n        )\n        .map_err(|e| SinkError::Config(anyhow!(e)))?;\n        Ok(config)\n    }\n\n    pub fn build_client(&self, connector: &str) -> Result<ElasticSearchOpenSearchClient> {\n        let check_username_password = || -> Result<()> {\n            if self.username.is_some() && self.password.is_none() {\n                return Err(SinkError::Config(anyhow!(\n                    \"please set the password when the username is set.\"\n                )));\n            }\n            if self.username.is_none() && self.password.is_some() {\n                return Err(SinkError::Config(anyhow!(\n                    \"please set the username when the password is set.\"\n                )));\n            }\n            Ok(())\n        };\n        let url =\n            Url::parse(&self.url).map_err(|e| SinkError::ElasticSearchOpenSearch(anyhow!(e)))?;\n        if connector.eq(ES_SINK) {\n            let mut transport_builder = elasticsearch::http::transport::TransportBuilder::new(\n                elasticsearch::http::transport::SingleNodeConnectionPool::new(url),\n            );\n            if let Some(username) = &self.username\n                && let Some(password) = &self.password\n            {\n                transport_builder = transport_builder.auth(\n                    elasticsearch::auth::Credentials::Basic(username.clone(), password.clone()),\n                );\n            }","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/elasticsearch_opensearch/elasticsearch_opensearch_config.rs#L180-L216","documentation":"Configuration check in ElasticSearchOpenSearchConfig::build_client: a password was provided without a username. Both must be set together for basic-authenticated clients; a password-only configuration is rejected before creating the Elasticsearch/OpenSearch client.","triggerScenarios":"Sink/connection config contains `password` but no `username` when new() calls build_client.","commonSituations":"Username key typo (e.g. `user` instead of `username`); partially edited sink definitions; assuming password-only auth is supported.","solutions":["Add the matching `username` alongside `password`.","Verify the username option key is spelled exactly `username`.","Remove the password if the cluster is unauthenticated."],"exampleFix":"// before\nWITH (\n  'connector' = 'elasticsearch',\n  'url' = 'https://es.example.com:9200',\n  'password' = 'secret'\n)\n// after\nWITH (\n  'connector' = 'elasticsearch',\n  'url' = 'https://es.example.com:9200',\n  'username' = 'elastic',\n  'password' = 'secret'\n)","handlingStrategy":"validation","validationCode":"-- assert paired credentials before DDL\n-- WITH clause must contain both 'username' and 'password' or neither","typeGuard":null,"tryCatchPattern":"match err { SinkError::Config(e) if e.to_string().contains(\"username when the password\") => add_username_option(), _ => return Err(err) }","preventionTips":["Check the exact option spelling `username` (not `user`).","Keep credential options as a pair in templates/checklists.","Drop the password if the endpoint is unauthenticated."],"tags":["elasticsearch","opensearch","config","credentials","validation"],"backgroundTag":"missing-credentials","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}