{"record":{"id":"3364ac94b270c89c","repo":"MyCATApache/Mycat-Server","slug":"host-empty-in-node-name","errorCode":null,"errorMessage":"host empty in node: ${name}","messagePattern":"host empty in node: (.+?)","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/model/ClusterConfig.java","lineNumber":79,"sourceCode":"    }\n\n    private static Map<String, MycatNodeConfig> loadNode(Element root, int port) {\n        Map<String, MycatNodeConfig> nodes = new HashMap<String, MycatNodeConfig>();\n        NodeList list = root.getElementsByTagName(\"node\");\n        Set<String> hostSet = new HashSet<String>();\n        for (int i = 0, n = list.getLength(); i < n; i++) {\n            Node node = list.item(i);\n            if (node instanceof Element) {\n                Element element = (Element) node;\n                String name = element.getAttribute(\"name\").trim();\n                if (nodes.containsKey(name)) {\n                    throw new ConfigException(\"node name duplicated :\" + name);\n                }\n\n                Map<String, Object> props = ConfigUtil.loadElements(element);\n                String host = (String) props.get(\"host\");\n                if (null == host || \"\".equals(host)) {\n                    throw new ConfigException(\"host empty in node: \" + name);\n                }\n                if (hostSet.contains(host)) {\n                    throw new ConfigException(\"node host duplicated :\" + host);\n                }\n\n                String wei = (String) props.get(\"weight\");\n                if (null == wei || \"\".equals(wei)) {\n                    throw new ConfigException(\"weight should not be null in host:\" + host);\n                }\n                int weight = Integer.parseInt(wei);\n                if (weight <= 0) {\n                    throw new ConfigException(\"weight should be > 0 in host:\" + host + \" weight:\" + weight);\n                }\n\n                MycatNodeConfig conf = new MycatNodeConfig(name, host, port, weight);\n                nodes.put(name, conf);\n                hostSet.add(host);\n            }","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/model/ClusterConfig.java#L61-L97","documentation":"loadNode requires every <node> element in cluster.xml to define a non-empty 'host' property. If props.get(\"host\") is null or an empty string, ConfigException 'host empty in node: <name>' is thrown. The host is mandatory to contact the node.","triggerScenarios":"A <node name=\"X\"> element in cluster.xml lacks a <property name=\"host\"> child or its value is empty; thrown at ClusterConfig.java:79 during loadNode.","commonSituations":"Hand-edited cluster.xml where the host property line was deleted or left as <property name=\"host\"></property>, placeholder values like ${HOST} not substituted, or a misspelled property name (Host vs host).","solutions":["Add a host property to the offending node: <property name=\"host\">10.0.0.1</property>.","Check the property element name is exactly 'host' and the value is non-empty after trimming.","Replace unresolved placeholders (e.g. ${HOST}) with concrete hostnames/IPs.","Restart Mycat after fixing cluster.xml."],"exampleFix":"<!-- before -->\n<node name=\"nodeM1\">\n  <property name=\"port\">3311</property>\n</node>\n<!-- after -->\n<node name=\"nodeM1\">\n  <property name=\"host\">10.0.0.1</property>\n  <property name=\"port\">3311</property>\n</node>","handlingStrategy":"validation","validationCode":"// Every <node> must have a non-empty host property\nvar nl = doc.getElementsByTagName(\"node\");\nfor (int i = 0; i < nl.getLength(); i++) {\n  var el = (Element) nl.item(i);\n  var props = el.getElementsByTagName(\"property\");\n  boolean hasHost = false;\n  for (int j = 0; j < props.getLength(); j++) {\n    var p = (Element) props.item(j);\n    if (\"host\".equals(p.getAttribute(\"name\")) && !p.getTextContent().trim().isEmpty()) hasHost = true;\n  }\n  if (!hasHost) throw new IllegalStateException(\"node \" + el.getAttribute(\"name\") + \" missing host\");\n}","typeGuard":null,"tryCatchPattern":"try { new ClusterConfig(); } catch (ConfigException e) { if (e.getMessage().startsWith(\"host empty in node\")) { log.error(\"Add host property to node in cluster.xml\"); } throw e; }","preventionTips":["Use a node XML template that includes host/port/weight","Substitute placeholders (${HOST}) before deploying","Keep property names exactly lowercase: host, port, weight","Validate cluster.xml with a schema or script in CI"],"tags":["xml","config","missing-property","cluster","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-23T08:17:48.524Z"}