{"record":{"id":"fe5d4a2104da04b8","repo":"apache/shenyu","slug":"sync-consul-url-can-not-be-null-consulsyncdataconfiguration","errorCode":null,"errorMessage":"sync.consul.url can not be null.","messagePattern":"sync\\.consul\\.url can not be null\\.","errorType":"validation","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-spring-boot-starter/shenyu-spring-boot-starter-sync-data-center/shenyu-spring-boot-starter-sync-data-consul/src/main/java/org/apache/shenyu/springboot/sync/data/consul/ConsulSyncDataConfiguration.java","lineNumber":105,"sourceCode":"     * @return the consul config\n     */\n    @Bean\n    @ConfigurationProperties(prefix = \"shenyu.sync.consul\")\n    public ConsulConfig consulConfig() {\n        return new ConsulConfig();\n    }\n\n\n    /**\n     * init Consul client.\n     * @param consulConfig the consul config\n     * @return Consul client\n     */\n    @Bean\n    public ConsulClient consulClient(final ConsulConfig consulConfig) {\n        String url = consulConfig.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","sourceCodeStart":87,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-spring-boot-starter/shenyu-spring-boot-starter-sync-data-center/shenyu-spring-boot-starter-sync-data-consul/src/main/java/org/apache/shenyu/springboot/sync/data/consul/ConsulSyncDataConfiguration.java#L87-L115","documentation":"The Consul data-sync configuration requires the Consul agent URL. If shenyu.sync.consul.url is blank, the consulClient bean throws this ShenyuException; a non-blank but malformed URL throws the companion 'formatter is not incorrect' error.","triggerScenarios":"Using the consul data-sync starter without setting shenyu.sync.consul.url, or setting it to an empty/whitespace string.","commonSituations":"Switching sync type to consul without adding the url key; env var substitution resolving to empty; config placed under the wrong prefix (e.g. spring.cloud.consul instead of shenyu.sync.consul).","solutions":["Set shenyu.sync.consul.url (e.g. http://127.0.0.1:8500)","Ensure the key is under shenyu.sync.consul, not another prefix","Check that the property source (yml/env) supplying the URL is actually active"],"exampleFix":"# before\nshenyu:\n  sync:\n    consul: {}\n# after\nshenyu:\n  sync:\n    consul:\n      url: http://127.0.0.1:8500","handlingStrategy":"validation","validationCode":"String url = env.getProperty(\"shenyu.sync.consul.url\");\nif (StringUtils.isBlank(url)) {\n    throw new IllegalArgumentException(\"shenyu.sync.consul.url is required for consul data sync\");\n}\nnew URL(url); // also fail fast on malformed values","typeGuard":null,"tryCatchPattern":"try {\n    consulClient = ctx.getBean(ConsulClient.class);\n} catch (Exception e) {\n    if (rootCauseOf(e, ShenyuException.class).map(x -> x.getMessage().contains(\"sync.consul.url\")).orElse(false)) {\n        log.error(\"Set shenyu.sync.consul.url, e.g. http://127.0.0.1:8500\");\n    } else throw e;\n}","preventionTips":["Keep sync config under the shenyu.sync.consul prefix, not spring.cloud.consul","Validate the URL scheme/host/port in config tests","Check env substitution resolves to a non-empty value in every environment"],"tags":["consul","data-sync","configuration","missing-url"],"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"}