{"record":{"id":"4915682cb44456cb","repo":"MyCATApache/Mycat-Server","slug":"weight-should-not-be-null-in-host-host","errorCode":null,"errorMessage":"weight should not be null in host:${host}","messagePattern":"weight should not be null in host:(.+?)","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/model/ClusterConfig.java","lineNumber":87,"sourceCode":"            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            }\n        }\n        return nodes;\n    }\n\n    private static Map<String, List<String>> loadGroup(Element root, Map<String, MycatNodeConfig> nodes) {\n        Map<String, List<String>> groups = new HashMap<String, List<String>>();\n        NodeList list = root.getElementsByTagName(\"group\");\n        for (int i = 0, n = list.getLength(); i < n; i++) {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/model/ClusterConfig.java#L69-L105","documentation":"Every <node> in cluster.xml must define a non-empty 'weight' property used for load balancing. If the weight value is null or empty, ConfigException 'weight should not be null in host: <host>' is thrown at ClusterConfig.java:87.","triggerScenarios":"A node element defines host and port but omits <property name=\"weight\"> or leaves it empty; thrown during loadNode.","commonSituations":"Adding a new node and forgetting the weight line, an older cluster.xml upgraded to a Mycat version that made weight mandatory, or a template with placeholder ${WEIGHT} left unsubstituted.","solutions":["Add a positive integer weight to the node: <property name=\"weight\">1</property>.","Set weights proportional to node capacity (e.g. bigger machine = higher weight).","Check for misspelled property names or unsubstituted placeholders.","Restart Mycat to reload cluster.xml."],"exampleFix":"<!-- before -->\n<node name=\"nodeM1\" host=\"10.0.0.1\">\n  <property name=\"port\">3311</property>\n</node>\n<!-- after -->\n<node name=\"nodeM1\" host=\"10.0.0.1\">\n  <property name=\"port\">3311</property>\n  <property name=\"weight\">1</property>\n</node>","handlingStrategy":"validation","validationCode":"// Every node must declare a non-empty weight\nvar nl = doc.getElementsByTagName(\"node\");\nfor (int i = 0; i < nl.getLength(); i++) {\n  var el = (Element) nl.item(i);\n  String w = propOf(el, \"weight\");\n  if (w == null || w.trim().isEmpty()) throw new IllegalStateException(\"node \" + el.getAttribute(\"name\") + \" missing weight\");\n}","typeGuard":null,"tryCatchPattern":"try { new ClusterConfig(); } catch (ConfigException e) { if (e.getMessage().startsWith(\"weight should not be null\")) { log.error(\"Add weight property to node in cluster.xml\"); } throw e; }","preventionTips":["Always set weight when adding nodes to cluster.xml","Compare your config against the sample cluster.xml shipped with Mycat","Unsubstituted placeholders like ${WEIGHT} must be replaced","Validate node fields (name/host/port/weight) in CI"],"tags":["xml","config","missing-property","load-balancing","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"}