{"record":{"id":"39cd521958b8c922","repo":"apache/shenyu","slug":"sync-consul-url-can-not-be-null","errorCode":null,"errorMessage":"sync.consul.url can not be null.","messagePattern":"sync\\.consul\\.url can not be null\\.","errorType":"exception","errorClass":"ShenyuException","httpStatus":null,"severity":"critical","filePath":"shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/config/ConsulSyncConfiguration.java","lineNumber":55,"sourceCode":"/**\n * The type Consul listener.\n */\n@Configuration\n@ConditionalOnProperty(prefix = \"shenyu.sync.consul\", name = \"url\")\n@EnableConfigurationProperties(ConsulProperties.class)\npublic class ConsulSyncConfiguration {\n\n    /**\n     * init Consul client.\n     *\n     * @param consulProperties the consul properties\n     * @return Consul client\n     */\n    @Bean\n    public ConsulClient consulClient(final ConsulProperties consulProperties) {\n        String url = consulProperties.getUrl();\n        if (StringUtils.isBlank(url)) {\n            throw new ShenyuException(\"sync.consul.url can not be null.\");\n        }\n        try {\n            URL consulUrl = new URL(url);\n            return consulUrl.getPort() < 0 ? new ConsulClient(consulUrl.getHost()) : new ConsulClient(consulUrl.getHost(), consulUrl.getPort());\n        } catch (MalformedURLException e) {\n            throw new ShenyuException(\"sync.consul.url formatter is not incorrect.\");\n        }\n    }\n\n    /**\n     * Config event listener data changed listener.\n     *\n     * @param consulClient the consul client\n     * @return the data changed listener\n     */\n    @Bean\n    @ConditionalOnMissingBean(ConsulDataChangedListener.class)\n    public DataChangedListener consulDataChangedListener(final ConsulClient consulClient) {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/config/ConsulSyncConfiguration.java#L37-L73","documentation":"ConsulSyncConfiguration.consulClient builds the ConsulClient bean from sync.consul.url in ConsulProperties. If the URL property is blank, the configuration cannot know where Consul lives, so a ShenyuException is thrown at bean creation time, failing application startup.","triggerScenarios":"Starting shenyu-admin with the consul data-sync listener enabled but shenyu.consul.url (sync.consul.url) unset or empty in application.yml/properties.","commonSituations":"Enabling the consul sync dependency without adding its configuration block, copying a config template and leaving the URL placeholder empty, or an environment-specific profile that omits the property.","solutions":["Set sync.consul.url (e.g. http://localhost:8500) in application.yml for the active profile.","Confirm the ConsulProperties prefix/binding matches the key you set (check the @ConfigurationProperties prefix).","Disable the consul listener module if you do not use Consul sync.","Provide the value via environment variable (e.g. SYNC_CONSUL_URL) in containerized deployments."],"exampleFix":"# before (application.yml)\nconsul:\n  url:\n# after\nconsul:\n  url: http://localhost:8500","handlingStrategy":"validation","validationCode":"String url = properties.getUrl();\nif (url == null || url.isBlank()) { throw new IllegalStateException(\"sync.consul.url must be set before enabling consul sync\"); }","typeGuard":"boolean consulUrlPresent(Map<String,String> cfg) { String u = cfg.get(\"sync.consul.url\"); return u != null && !u.isBlank(); }","tryCatchPattern":"try { new ConsulSyncConfiguration().consulClient(props); } catch (ShenyuException e) { log.error(\"Consul URL missing: {}\", e.getMessage()); /* fail startup or fall back */ }","preventionTips":["Fail fast in CI by asserting required properties exist per profile.","Use env var fallbacks (SYNC_CONSUL_URL) in container deployments.","Document required properties per data-sync module in the deploy guide.","Only include the consul listener dependency when Consul sync is actually used."],"tags":["consul","config-sync","missing-config"],"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"}