{"record":{"id":"7c1a55e1a4117071","repo":"apache/shenyu","slug":"zookeeper-url-is-empty","errorCode":null,"errorMessage":"zookeeper url is empty","messagePattern":"zookeeper url is empty","errorType":"validation","errorClass":"ShenyuException","httpStatus":null,"severity":"critical","filePath":"shenyu-infra/shenyu-infra-zookeeper/src/main/java/org/apache/shenyu/infra/zookeeper/autoconfig/ZookeeperConfiguration.java","lineNumber":68,"sourceCode":"    private static final Integer DEFAULT_BASE_SLEEP_TIME = 1000;\n\n    private static final Integer DEFAULT_MAX_SLEEP_TIME = Integer.MAX_VALUE;\n\n    private static final Integer DEFAULT_MAX_RETRIES = 3;\n\n    /**\n     * Zookeeper client bean.\n     *\n     * @param zookeeperProperties zookeeper properties\n     * @return ZookeeperClient\n     */\n    @Bean\n    @ConditionalOnMissingBean(ZookeeperClient.class)\n    public ZookeeperClient zookeeperClient(final ZookeeperProperties zookeeperProperties) {\n\n        ZookeeperConfig config = zookeeperProperties.getZookeeper();\n        if (!StringUtils.hasText(config.getUrl())) {\n            throw new ShenyuException(\"zookeeper url is empty\");\n        }\n        if (Objects.isNull(config.getBaseSleepTimeMilliseconds())) {\n            config.setBaseSleepTimeMilliseconds(DEFAULT_BASE_SLEEP_TIME);\n        }\n        if (Objects.isNull(config.getMaxSleepTimeMilliseconds())) {\n            config.setMaxSleepTimeMilliseconds(DEFAULT_MAX_SLEEP_TIME);\n        }\n        if (Objects.isNull(config.getMaxRetries())) {\n            config.setMaxRetries(DEFAULT_MAX_RETRIES);\n        }\n        if (Objects.isNull(config.getSessionTimeoutMilliseconds())) {\n            config.setSessionTimeoutMilliseconds(DEFAULT_SESSION_TIMEOUT);\n        }\n        if (Objects.isNull(config.getConnectionTimeoutMilliseconds())) {\n            config.setConnectionTimeoutMilliseconds(DEFAULT_CONNECT_TIMEOUT);\n        }\n\n        LOG.info(\"init zookeeper client, config: {}\", config);","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-infra/shenyu-infra-zookeeper/src/main/java/org/apache/shenyu/infra/zookeeper/autoconfig/ZookeeperConfiguration.java#L50-L86","documentation":"ZookeeperConfiguration.zookeeperClient builds the ZookeeperClient bean from ZookeeperProperties. Before connecting it verifies that the configured zookeeper URL has text; if it is null/blank it throws ShenyuException('zookeeper url is empty'). ZooKeeper is a mandatory dependency for the zookeeper sync mode, so the app cannot proceed without it.","triggerScenarios":"Starting the application with shenyu.sync.zookeeper.url unset or empty while the zookeeper data-sync/registration mode is enabled.","commonSituations":"Missing property in application.yml when switching sync modes, environment variable not set in Docker/Kubernetes, property name typo so the value never binds.","solutions":["Set the zookeeper URL in configuration: shenyu.sync.zookeeper.url=127.0.0.1:2181","Verify the exact property path matches the version's ZookeeperProperties binding (zookeeper.url inside the config object)","Ensure the environment variable or ConfigMap providing the URL is actually mounted and named correctly","Check application logs/startup binding to confirm the property was read"],"exampleFix":"// before (application.yml)\nshenyu:\n  sync:\n    zookeeper:\n      url:\n// after\nshenyu:\n  sync:\n    zookeeper:\n      url: 127.0.0.1:2181","handlingStrategy":"validation","validationCode":"String url = env.getProperty(\"shenyu.sync.zookeeper.url\");\nif (url == null || url.isBlank()) {\n    throw new IllegalStateException(\"shenyu.sync.zookeeper.url must be set\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    context = SpringApplication.run(App.class, args);\n} catch (Exception e) {\n    if (e.getCause() instanceof ShenyuException && e.getMessage().contains(\"zookeeper url is empty\")) {\n        log.error(\"Set shenyu.sync.zookeeper.url before enabling zookeeper sync\");\n    }\n    throw e;\n}","preventionTips":["Always configure shenyu.sync.zookeeper.url when using zookeeper sync","Supply it via env var/ConfigMap in container deployments","Verify property key spelling against the properties class","Fail fast in CI config checks before deployment"],"tags":["zookeeper","configuration","startup"],"backgroundTag":"missing-required-config-field","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}