{"record":{"id":"83498a12d28b3de3","repo":"MyCATApache/Mycat-Server","slug":"selfcheck-schema-all-node-is-empty","errorCode":null,"errorMessage":"SelfCheck### schema all node is empty!","messagePattern":"SelfCheck### schema all node is empty!","errorType":"exception","errorClass":"io.mycat.config.ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/ConfigInitializer.java","lineNumber":152,"sourceCode":"\t\t\t\tSet<String> authSchemas = uc.getSchemas();\n\t\t\t\tif (authSchemas == null) {\n\t\t\t\t\tthrow new ConfigException(\"SelfCheck### user \" + uc.getName() + \"refered schemas is empty!\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor (String schema : authSchemas) {\n\t\t\t\t\tif ( !schemas.containsKey(schema) ) {\n\t\t\t\t\t\tString errMsg = \"SelfCheck###  schema \" + schema + \" refered by user \" + uc.getName() + \" is not exist!\";\n\t\t\t\t\t\tthrow new ConfigException(errMsg);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\t\n\t\t\n\t\t// schema 配置检测\t\t\n\t\tfor (SchemaConfig sc : schemas.values()) {\n\t\t\tif (null == sc) {\n\t\t\t\tthrow new ConfigException(\"SelfCheck### schema all node is empty!\");\n\t\t\t\t\n\t\t\t} else {\t\t\t\t\n\t\t\t\t// check dataNode / dataHost 节点\n\t\t\t\tif ( this.dataNodes != null &&  this.dataHosts != null  ) {\t\t\t\t\t\n\t\t\t\t\tSet<String> dataNodeNames = sc.getAllDataNodes();\n\t\t\t\t\tfor(String dataNodeName: dataNodeNames) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tPhysicalDBNode node = this.dataNodes.get(dataNodeName);\n\t\t\t\t\t\tif ( node == null ) {\n\t\t\t\t\t\t\tthrow new ConfigException(\"SelfCheck### schema dbnode is empty!\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\t\n\t}\n\t","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/ConfigInitializer.java#L134-L170","documentation":"Thrown by ConfigInitializer.selfChecking0 during the schema configuration check when a SchemaConfig value in the schemas map is null. The schemas map is expected to contain only fully-parsed schema configurations; a null entry indicates an internal parsing/registration invariant was violated, so startup aborts with ConfigException.","triggerScenarios":"ConfigInitializer constructor where the schemas map built from schema.xml contains a null SchemaConfig value — typically from custom/modified loading code or corrupted merge of schema definitions rather than ordinary config typos.","commonSituations":"Custom forks or patches to MyCat config loading that put entries into the map without a valid SchemaConfig; programmatic construction of the config map in tests/embedding code where a schema was registered as null; corrupted config reload state.","solutions":["Review schema.xml for malformed <schema> definitions (missing name attribute, unclosed tags) that could parse to a null entry.","If using a custom/patched ConfigInitializer, verify every put into the schemas map passes a non-null SchemaConfig.","Restore stock MyCat config-loading code if it was modified.","Restart with a known-good schema.xml to isolate whether the file or the loader is at fault."],"exampleFix":"// before (custom loader)\nschemas.put(schemaName, parseSchema(cfg)); // may be null\n// after\nSchemaConfig sc = parseSchema(cfg);\nif (sc == null) {\n    throw new ConfigException(\"schema \" + schemaName + \" failed to parse\");\n}\nschemas.put(schemaName, sc);","handlingStrategy":"try-catch","validationCode":"// Check schemas map for null entries before handing to self-check\nschemas.values().forEach(sc -> {\n    if (sc == null) throw new IllegalStateException(\"null SchemaConfig in schemas map\");\n});","typeGuard":"boolean isValidSchemaMap(Map<String, SchemaConfig> schemas) {\n    return schemas != null && schemas.values().stream().noneMatch(java.util.Objects::isNull);\n}","tryCatchPattern":"try {\n    new ConfigInitializer(...);\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"schema all node is empty\")) {\n        LOGGER.error(\"Null SchemaConfig registered; check config loader/fork: {}\", e.getMessage());\n    } else { throw e; }\n}","preventionTips":["Do not modify ConfigInitializer loading logic without null-checks on put().","Validate schema.xml well-formedness (XML parse) before MyCat startup.","Avoid programmatic registration of null schema entries in embedded usage.","Pin config-loading code to the stock version during upgrades."],"tags":["config","startup","mycat","null-check"],"backgroundTag":"internal-invariant-violation","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"}