{"record":{"id":"82c2c1980b0aa99c","repo":"apache/dubbo","slug":"illegal-route-rule","errorCode":null,"errorMessage":"Illegal route rule!","messagePattern":"Illegal route rule!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionStateRouter.java","lineNumber":109,"sourceCode":"        }\n    }\n\n    public ConditionStateRouter(URL url) {\n        super(url);\n        this.setUrl(url);\n        this.setForce(url.getParameter(FORCE_KEY, false));\n        matcherFactories =\n                moduleModel.getExtensionLoader(ConditionMatcherFactory.class).getActivateExtensions();\n        this.enabled = url.getParameter(ENABLED_KEY, true);\n        if (enabled) {\n            init(url.getParameterAndDecoded(RULE_KEY));\n        }\n    }\n\n    public void init(String rule) {\n        try {\n            if (rule == null || rule.trim().length() == 0) {\n                throw new IllegalArgumentException(\"Illegal route rule!\");\n            }\n            rule = rule.replace(\"consumer.\", \"\").replace(\"provider.\", \"\");\n            int i = rule.indexOf(\"=>\");\n            String whenRule = i < 0 ? null : rule.substring(0, i).trim();\n            String thenRule = i < 0 ? rule.trim() : rule.substring(i + 2).trim();\n            Map<String, ConditionMatcher> when =\n                    StringUtils.isBlank(whenRule) || \"true\".equals(whenRule) ? new HashMap<>() : parseRule(whenRule);\n            Map<String, ConditionMatcher> then =\n                    StringUtils.isBlank(thenRule) || \"false\".equals(thenRule) ? null : parseRule(thenRule);\n            // NOTE: It should be determined on the business level whether the `When condition` can be empty or not.\n            this.whenCondition = when;\n            this.thenCondition = then;\n        } catch (ParseException e) {\n            throw new IllegalStateException(e.getMessage(), e);\n        }\n    }\n\n    private Map<String, ConditionMatcher> parseRule(String rule) throws ParseException {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionStateRouter.java#L91-L127","documentation":"Thrown by ConditionStateRouter.init() when the route rule is null or blank. The condition state router is driven by a 'rule' URL parameter (URL-encoded, e.g. 'consumer.region=-east => provider.region=east'); enabling the router without that rule is invalid.","triggerScenarios":"Configuring the condition state router (SPI 'condition') with enabled=true (the default) but the 'rule' parameter is missing or empty in the router URL. init(url.getParameterAndDecoded(RULE_KEY)) receives null/blank.","commonSituations":"Publishing a condition routing rule that omits the rule body; URL-encoding the rule incorrectly so it decodes to empty; a registry/notification glitch delivering a rule URL without its rule param.","solutions":["Provide a non-empty condition rule, e.g. rule: 'consumer.host = 10.20.* => provider.host = 10.20.*'.","If you do not need condition routing, set enabled=false or remove the router URL.","Verify the rule survives URL-encoding/decoding (use the encoded form in override:// URLs)."],"exampleFix":"# before (broken): condition router enabled, no rule\noverride://0.0.0.0/...?router=condition&condition.router.enabled=true\n\n# after (URL-encode the rule)\noverride://0.0.0.0/...?router=condition&condition.router.enabled=true&rule=consumer.region%3D east %3D%3E provider.region%3D east","handlingStrategy":"validation","validationCode":"// Validate condition router rule before constructing\nString rule = url.getParameterAndDecoded(RULE_KEY);\nboolean enabled = url.getParameter(ENABLED_KEY, true);\nif (enabled && (rule == null || rule.trim().isEmpty())) {\n    throw new IllegalArgumentException(\n        \"Condition router enabled but 'rule' is empty; provide a rule or disable the router.\");\n}\nreturn new ConditionStateRouter<>(url);","typeGuard":null,"tryCatchPattern":"try {\n    new ConditionStateRouter<>(url);\n} catch (IllegalArgumentException | IllegalStateException e) {\n    // bad condition rule; fall back to no condition routing\n    log.error(\"Condition router disabled due to bad rule: \" + e.getMessage());\n    url = url.addParameter(ENABLED_KEY, false);\n}","preventionTips":["Always include a non-empty rule when enabling the condition router.","URL-encode the rule correctly so it survives registry round-trips.","Disable the router rather than publishing an empty rule."],"tags":["router","condition","config","validation"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}