{"record":{"id":"ce0327f9ecd02883","repo":"apache/shenyu","slug":"shenyu-register-serverlists-can-not-be-null","errorCode":null,"errorMessage":"shenyu.register.serverLists can not be null.","messagePattern":"shenyu\\.register\\.serverLists can not be null\\.","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":105,"sourceCode":"\n    private TtlScheduler ttlScheduler;\n\n    private final Map<String, List<InstanceEntity>> watcherInstanceRegisterMap = new ConcurrentHashMap<>();\n\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());","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-registry/shenyu-registry-consul/src/main/java/org/apache/shenyu/registry/consul/ConsulInstanceRegisterRepository.java#L87-L123","documentation":"ConsulInstanceRegisterRepository.init validates shenyu.register.serverLists before constructing the ConsulClient; a blank value means the gateway has nowhere to register/select instances, so a ShenyuException is thrown during repository initialization.","triggerScenarios":"init() (e.g. from testSelectInstancesAndWatcher or Spring wiring) runs with shenyu.register.serverLists unset or empty in the register config.","commonSituations":"Using the consul registry module without adding shenyu.register.serverLists to application.yml; config file not loaded (wrong profile); property renamed/moved between versions.","solutions":["Set shenyu.register.serverLists to the Consul address, e.g. http://localhost:8500","Confirm the config file/profile containing the property is actually loaded","Verify you are using the consul registerType/registry module intentionally","Check property name against the module's documentation for your version"],"exampleFix":"// before\nshenyu:\n  register:\n    registerType: consul\n# serverLists missing\n// after\nshenyu:\n  register:\n    registerType: consul\n    serverLists: http://localhost:8500","handlingStrategy":"validation","validationCode":"String sl = config.getServerLists(); if (sl == null || sl.isBlank()) throw new IllegalArgumentException(\"set shenyu.register.serverLists for consul\");","typeGuard":null,"tryCatchPattern":"try { repository.init(); } catch (ShenyuException e) { log.error(\"consul register config invalid: {}\", e.getMessage()); System.exit(1); }","preventionTips":["Set serverLists in every environment's config for the consul module","Fail fast at startup with a config self-check","Keep property names in sync with the module docs"],"tags":["consul","registry","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"}