{"record":{"id":"8313c60bf2eb10bd","repo":"MyCATApache/Mycat-Server","slug":"no-rule-is-found","errorCode":null,"errorMessage":"no rule is found","messagePattern":"no rule is found","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/model/rule/TableRuleConfig.java","lineNumber":41,"sourceCode":" */\npackage io.mycat.config.model.rule;\n\nimport java.io.Serializable;\n\n/**\n * @author mycat\n */\npublic class TableRuleConfig implements Serializable {\n    private  String name;\n    private final RuleConfig rule;\n\n    public TableRuleConfig(String name, RuleConfig rule) {\n        if (name == null) {\n            throw new IllegalArgumentException(\"name is null\");\n        }\n        this.name = name;\n        if (rule == null) {\n            throw new IllegalArgumentException(\"no rule is found\");\n        }\n        this.rule =rule;\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    /**\n     * @return unmodifiable\n     */\n    public RuleConfig getRule() {\n        return rule;\n    }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/model/rule/TableRuleConfig.java#L23-L59","documentation":"TableRuleConfig's constructor throws IllegalArgumentException when the RuleConfig argument is null. The library requires every named table rule to have a non-null rule object, so a null rule is rejected immediately at construction time. This fails fast rather than allowing a half-initialized table rule to break routing later.","triggerScenarios":"Calling new TableRuleConfig(name, null) — e.g. when building a table rule programmatically or when config parsing produced a RuleConfig object that was null but a name was present.","commonSituations":"schema.xml / rule.xml misconfiguration where a <table> references a rule name that failed to load; initialization code passing an uninitialized RuleConfig; unit tests constructing rules manually.","solutions":["Check that the RuleConfig passed to the constructor is non-null before constructing TableRuleConfig","Verify the rule referenced in schema.xml exists and was successfully parsed from rule.xml","Fix any earlier load failure (check logs/warnings during rule loading) that left the RuleConfig null"],"exampleFix":"// before\nTableRuleConfig trc = new TableRuleConfig(\"order\", ruleMap.get(\"orderRule\")); // null if key missing\n// after\nRuleConfig rc = ruleMap.get(\"orderRule\");\nif (rc == null) { throw new ConfigException(\"rule 'orderRule' not defined in rule.xml\"); }\nTableRuleConfig trc = new TableRuleConfig(\"order\", rc);","handlingStrategy":"validation","validationCode":"if (rule == null) { throw new ConfigException(\"table '\" + name + \"' has no matching rule; check rule.xml\"); }\nTableRuleConfig trc = new TableRuleConfig(name, rule);","typeGuard":null,"tryCatchPattern":"try { new TableRuleConfig(name, rule); } catch (IllegalArgumentException e) { log.error(\"bad table rule: {}\", e.getMessage()); throw e; }","preventionTips":["Always resolve RuleConfig from the parsed rule map and assert non-null before construction","Fail fast at config load with a message naming the missing rule","Add a startup self-check that every <table> rule reference resolves"],"tags":["config","null-argument","sharding"],"backgroundTag":"null-argument","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"}