{"record":{"id":"47a789756849868c","repo":"MyCATApache/Mycat-Server","slug":"user-user-doesn-t-exist-in-host-hoststr","errorCode":null,"errorMessage":"[user: ${user}] doesn't exist in [host: ${hostStr}]","messagePattern":"\\[user: (.+?)\\] doesn't exist in \\[host: (.+?)\\]","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/loader/xml/XMLServerLoader.java","lineNumber":161,"sourceCode":"            Node node = list.item(i);\n            if (node instanceof Element) {\n                Element e = (Element) node;\n                String hostStr = e.getAttribute(\"host\").trim();\n                String userStr = e.getAttribute(\"user\").trim();\n                String []hosts = hostStr.split(\",\");\n                for (String host : hosts) {\n                    host = host.trim();\n                    if (this.firewall.existsHost(host)) {\n                        throw new ConfigException(\"host duplicated : \" + host);\n                    }\n                }\n                String []users = userStr.split(\",\");\n                List<UserConfig> userConfigs = new ArrayList<UserConfig>();\n                for(String user : users){\n                    user = user.trim();\n                \tUserConfig uc = this.users.get(user);\n                    if (null == uc) {\n                        throw new ConfigException(\"[user: \" + user + \"] doesn't exist in [host: \" + hostStr + \"]\");\n                    }\n                    if (uc.getSchemas() == null || uc.getSchemas().size() == 0) {\n                        throw new ConfigException(\"[host: \" + hostStr + \"] contains one root privileges user: \" + user);\n                    }\n                    userConfigs.add(uc);\n                }\n                for (String host : hosts) {\n                    host = host.trim();\n                    if (host.contains(\"*\") || host.contains(\"%\")) {\n                        whitehostMask.put(FirewallConfig.getMaskPattern(host), userConfigs);\n                    } else {\n                        whitehost.put(host, userConfigs);\n                    }\n                }\n            }\n        }\n\n        firewall.setWhitehost(whitehost);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/xml/XMLServerLoader.java#L143-L179","documentation":"In loadFirewall, every user named in a <host user=\"...\"> whitelist entry must already exist in the <user> section of server.xml. XMLServerLoader looks the user up in its users map and throws this ConfigException if it is null — i.e., the firewall references a user that was never defined or whose definition failed to load.","triggerScenarios":"server.xml contains <host host=\"...\" user=\"alice\"> but no <user name=\"alice\"> element exists (or it is misspelled / commented out); firewall section is parsed after users are loaded, so the lookup misses.","commonSituations":"Renaming a user in the <user> section but not in the firewall whitelist; typo in the user attribute; deleting a user while leaving stale firewall entries; environment-specific overlays where users differ per env.","solutions":["Add the missing <user name=\"...\"> definition to server.xml, or correct the spelling in the firewall's user attribute to match an existing user","Remove stale firewall user references for users that were intentionally deleted","Grep server.xml to cross-check every user listed in <firewall> against defined <user> names before deploying","Restart MyCat and verify the server.xml loads"],"exampleFix":"// before\n<user name=\"alice\">...</user> removed, but firewall has:\n<host host=\"10.0.0.1\" user=\"alice\"/>\n// after\n<host host=\"10.0.0.1\" user=\"bob\"/>  <!-- or re-add the alice <user> definition -->","handlingStrategy":"validation","validationCode":"// verify firewall users exist in the <user> section\nSet<String> defined = new HashSet<>();\nNodeList us = doc.getElementsByTagName(\"user\");\nfor (int i = 0; i < us.getLength(); i++)\n    defined.add(((Element) us.item(i)).getAttribute(\"name\"));\nfor each firewall host element:\n    for (String u : e.getAttribute(\"user\").split(\",\"))\n        if (!defined.contains(u.trim())) throw new IllegalStateException(\"Firewall references unknown user: \" + u);","typeGuard":"null","tryCatchPattern":"try {\n    serverLoader.load();\n} catch (ConfigException e) {\n    LOG.error(\"Firewall references undefined user: \" + e.getMessage());\n    throw new ConfigurationException(\"Define the user or fix the firewall entry\", e);\n}","preventionTips":["When renaming/deleting users, grep server.xml for all references including firewall entries","Keep a single source of truth for user definitions across environments","Validate user references in CI before deploying server.xml"],"tags":["configuration","firewall","user"],"backgroundTag":"record-not-found","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"}