{"record":{"id":"222af3965a27aa5b","repo":"apache/shenyu","slug":"shenyu-register-serverlists-formatter-is-not-incorrect","errorCode":null,"errorMessage":"shenyu.register.serverLists formatter is not incorrect.","messagePattern":"shenyu\\.register\\.serverLists formatter is not incorrect\\.","errorType":"validation","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-registry/shenyu-registry-consul/src/main/java/org/apache/shenyu/registry/consul/ConsulInstanceRegisterRepository.java","lineNumber":109,"sourceCode":"\n    private final Set<String> watchSelectKeySet = ConcurrentHashMap.newKeySet();\n\n    @Override\n    public void init(final RegisterConfig config) {\n        final Properties props = config.getProps();\n        this.checkTtl = props.getProperty(\"checkTtl\", \"5\");\n        this.token = props.getProperty(\"token\", \"\");\n        this.waitTime = props.getProperty(\"waitTime\", \"30\");\n        this.watchDelay = props.getProperty(\"watchDelay\", \"5\");\n        this.tags = props.getProperty(\"tags\");\n\n        final String serverList = config.getServerLists();\n        if (StringUtils.isBlank(serverList)) {\n            throw new ShenyuException(\"shenyu.register.serverLists can not be null.\");\n        }\n        final String[] addresses = serverList.split(\":\");\n        if (addresses.length != 2) {\n            throw new ShenyuException(\"shenyu.register.serverLists formatter is not incorrect.\");\n        }\n        consulClient = new ConsulClient(addresses[0], Integer.parseInt(addresses[1]));\n        this.ttlScheduler = new TtlScheduler(Integer.parseInt(checkTtl), consulClient);\n        Runtime.getRuntime().addShutdownHook(new Thread(this::close));\n    }\n\n    @Override\n    public void persistInstance(final InstanceEntity instance) {\n        String instanceNodeName = buildInstanceNodeName(instance);\n        this.newService = new NewService();\n        newService.setName(instance.getAppName());\n        newService.setId(String.join(\"-\", instance.getAppName(), instanceNodeName));\n        newService.setAddress(instance.getHost());\n        newService.setPort(instance.getPort());\n        newService.setCheck(createCheck());\n        if (StringUtils.isNotEmpty(tags)) {\n            newService.setTags(new ArrayList<>(Arrays.asList(tags.split(\",\"))));\n        }","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-registry/shenyu-registry-consul/src/main/java/org/apache/shenyu/registry/consul/ConsulInstanceRegisterRepository.java#L91-L127","documentation":"At ConsulInstanceRegisterRepository.init this ShenyuException is a startup validation guard: the 'shenyu.register.serverLists' property must be a single 'host:port' address, but after splitting on ':' the result does not have exactly 2 parts (e.g. missing port, extra colon, or a comma-separated multi-address list, which this simple parser does not support). It fires while building the ConsulClient during repository initialization (invoked from init of the register config), aborting gateway registration setup because the configured Consul address is malformed.","triggerScenarios":"serverLists configured without a port, with multiple colons (e.g. including a scheme like http://host:port), or a comma-separated multi-address list where one entry does not parse as host:port.","commonSituations":"Copying the consul URL with the http:// scheme (the extra ':' yields >2 parts); forgetting the port (0 parts after split beyond host); supplying several consul nodes in serverLists although this module expects a single host:port.","solutions":["Set serverLists to exactly host:port without scheme, e.g. 127.0.0.1:8500","Remove any http:// or https:// prefix from the value","Provide a single address, not a comma-separated list","Check the module README for the expected format in your version"],"exampleFix":"// before\nshenyu:\n  register:\n    serverLists: http://localhost:8500\n// after\nshenyu:\n  register:\n    serverLists: localhost:8500","handlingStrategy":"validation","validationCode":"String[] a = serverList.split(\":\"); if (a.length != 2 || a[0].isBlank() || a[1].isBlank()) throw new IllegalArgumentException(\"serverLists must be host:port without scheme\");","typeGuard":null,"tryCatchPattern":"try { repository.init(); } catch (ShenyuException e) { log.error(\"bad serverLists format, expected host:port\", e); }","preventionTips":["Never include http:// in consul serverLists","Provide exactly one host:port pair","Add a startup format check before building ConsulClient"],"tags":["consul","registry","config","url-format"],"backgroundTag":"invalid-argument-format","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"}