{"record":{"id":"9db573157edd7104","repo":"MyCATApache/Mycat-Server","slug":"clusterid-and-zkurl-and-myid-must-not-be-null-or-e","errorCode":null,"errorMessage":"clusterId and zkURL and myid must not be null or empty!","messagePattern":"clusterId and zkURL and myid must not be null or empty!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/main/java/io/mycat/config/loader/zkprocess/comm/ZkConfig.java","lineNumber":124,"sourceCode":"        try (InputStream configIS = ZkConfig.class.getResourceAsStream(ZK_CONFIG_FILE_NAME)) {\n            if (configIS == null) {\n                return null;\n            }\n\n            pros.load(configIS);\n        } catch (IOException e) {\n            LOGGER.error(\"ZkConfig LoadMyidPropersites error:\", e);\n            throw new RuntimeException(\"can't find myid properties file : \" + ZK_CONFIG_FILE_NAME);\n        }\n\n        // validate\n        String zkURL = pros.getProperty(ZkParamCfg.ZK_CFG_URL.getKey());\n        String myid = pros.getProperty(ZkParamCfg.ZK_CFG_MYID.getKey());\n\n        String clusterId = pros.getProperty(ZkParamCfg.ZK_CFG_CLUSTERID.getKey());\n\n        if (Strings.isNullOrEmpty(clusterId) ||Strings.isNullOrEmpty(zkURL) || Strings.isNullOrEmpty(myid)) {\n            throw new RuntimeException(\"clusterId and zkURL and myid must not be null or empty!\");\n        }\n        return pros;\n\n    }\n\n    public static void main(String[] args) {\n        String zk = ZkConfig.getInstance().getValue(ZkParamCfg.ZK_CFG_CLUSTERID);\n        System.out.println(zk);\n    }\n\n}\n","sourceCodeStart":106,"sourceCodeEnd":136,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkConfig.java#L106-L136","documentation":"After loading myid.properties, LoadMyidPropersites validates that clusterId, zkURL and myid are non-null and non-empty (using Guava Strings.isNullOrEmpty). If any of the three keys is missing or blank, it throws this RuntimeException. It is a startup fail-fast check for mandatory ZooKeeper connection properties.","triggerScenarios":"myid.properties loaded successfully but lacks any of: ZkParamCfg.ZK_CFG_URL (zkURL), ZkParamCfg.ZK_CFG_CLUSTERID (clusterId), ZkParamCfg.ZK_CFG_MYID (myid) keys, or the values are empty strings; thrown at ZkConfig.java:124 during ZkConfig startup.","commonSituations":"Fresh Mycat deployment where myid.properties was copied without filling in values, key names misspelled (case-sensitive properties keys), values commented out, or whitespace-only values left after editing.","solutions":["Open myid.properties and add/fix all three keys: zkURL, clusterId, myid with non-empty values.","Verify exact key names match ZkParamCfg's keys (e.g. zkURL=..., clusterId=..., myid=1) with no typos or extra whitespace.","Ensure the file actually being loaded is the one on the runtime classpath, not a stale copy elsewhere.","Set the three values via your deployment templating/env provisioning if the file is generated."],"exampleFix":"// before (myid.properties)\n#zkURL=\nclusterId=cluster-1\n\n// after\nzkURL=127.0.0.1:2181\nclusterId=cluster-1\nmyid=1","handlingStrategy":"validation","validationCode":"Properties pros = new Properties();\ntry (InputStream is = getClass().getResourceAsStream(\"/zkcnf/myid.properties\")) { pros.load(is); }\njava.util.List<String> missing = java.util.stream.Stream.of(\"zkURL\", \"clusterId\", \"myid\")\n    .filter(k -> com.google.common.base.Strings.isNullOrEmpty(pros.getProperty(k)))\n    .collect(java.util.stream.Collectors.toList());\nif (!missing.isEmpty()) throw new IllegalStateException(\"myid.properties missing keys: \" + missing);","typeGuard":null,"tryCatchPattern":"try { ZkConfig.initZk(); } catch (RuntimeException e) { if (e.getMessage().contains(\"must not be null or empty\")) { log.error(\"myid.properties is missing zkURL/clusterId/myid\"); } throw e; }","preventionTips":["Use a checked-in template of myid.properties with all three keys","Validate myid.properties in CI before deployment","Keep exact key names (zkURL, clusterId, myid) documented","Fail your deployment pipeline early if values are blank"],"tags":["zookeeper","config","validation","missing-keys","mycat"],"backgroundTag":"missing-required-config-field","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}