{"record":{"id":"446956827e43ea18","repo":"alibaba/spring-cloud-alibaba","slug":"zookeeperdatasource-server-addr-is-empty","errorCode":null,"errorMessage":"ZookeeperDataSource server-addr is empty","messagePattern":"ZookeeperDataSource server-addr is empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/main/java/com/alibaba/cloud/sentinel/datasource/config/ZookeeperDataSourceProperties.java","lineNumber":54,"sourceCode":"\t}\n\n\tprivate String serverAddr = \"localhost:2181\";\n\n\tprivate @Nullable String path;\n\n\tprivate @Nullable String groupId;\n\n\tprivate @Nullable String dataId;\n\n\t@Override\n\tpublic void preCheck(String dataSourceName) {\n\t\tif (StringUtils.isEmpty(serverAddr)) {\n\t\t\tEnvironment env = this.getEnv();\n\t\t\tif (env != null) {\n\t\t\t\tserverAddr = env.getProperty(\"spring.cloud.sentinel.datasource.zk.server-addr\", \"\");\n\t\t\t}\n\t\t\tif (StringUtils.isEmpty(serverAddr)) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"ZookeeperDataSource server-addr is empty\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic String getServerAddr() {\n\t\treturn serverAddr;\n\t}\n\n\tpublic void setServerAddr(String serverAddr) {\n\t\tthis.serverAddr = serverAddr;\n\t}\n\n\tpublic @Nullable String getPath() {\n\t\treturn path;\n\t}\n\n\tpublic void setPath(@Nullable String path) {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/main/java/com/alibaba/cloud/sentinel/datasource/config/ZookeeperDataSourceProperties.java#L36-L72","documentation":"Thrown by ZookeeperDataSourceProperties.preCheck when serverAddr is empty. Unlike other datasource properties, serverAddr has a default value ('localhost:2181'), so this error only fires when the property is explicitly set to empty OR cleared and the environment fallback also yields empty. The check first tries the env property 'spring.cloud.sentinel.datasource.zk.server-addr' as a fallback before throwing.","triggerScenarios":"Configuring a Sentinel datasource of type 'zk' with serverAddr explicitly set to empty string, or the default was overridden to empty AND spring.cloud.sentinel.datasource.zk.server-addr is also unset or empty. Since the field defaults to 'localhost:2181', this requires actively clearing it.","commonSituations":"1) Developer sets spring.cloud.sentinel.datasource.<name>.zk.server-addr to an empty string or a placeholder that resolves to empty. 2) A profile override clears the default by setting server-addr to blank. 3) Programmatic configuration that sets serverAddr to null or empty after construction.","solutions":["Set spring.cloud.sentinel.datasource.<name>.zk.server-addr=<zk-host:port> to a valid Zookeeper address, or set the global fallback spring.cloud.sentinel.datasource.zk.server-addr.","Remove any explicit empty-string override that clears the 'localhost:2181' default.","If using a placeholder (${ZK_ADDR}), ensure the environment variable is set to a non-empty value."],"exampleFix":"# before (broken — server-addr explicitly empty)\nspring:\n  cloud:\n    sentinel:\n      datasource:\n        ds1:\n          zk:\n            server-addr: \"\"\n            path: /sentinel/rules\n\n# after (fixed)\nspring:\n  cloud:\n    sentinel:\n      datasource:\n        ds1:\n          zk:\n            server-addr: zk.local:2181\n            path: /sentinel/rules","handlingStrategy":"validation","validationCode":"// Ensure serverAddr is set for zk Sentinel datasource\n// Note: defaults to 'localhost:2181' but can be explicitly cleared\nString serverAddr = props.getZk().getServerAddr();\nif (!StringUtils.hasText(serverAddr)) {\n    // Try the global fallback\n    serverAddr = env.getProperty(\"spring.cloud.sentinel.datasource.zk.server-addr\", \"localhost:2181\");\n    props.getZk().setServerAddr(serverAddr);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not explicitly set server-addr to an empty string — the default 'localhost:2181' is usually preferable.","Use the global fallback property spring.cloud.sentinel.datasource.zk.server-addr for shared ZK addresses across multiple datasources.","Validate ZK connectivity in a startup health check."],"tags":["sentinel","zookeeper","datasource","configuration","validation"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}