{"record":{"id":"50d2b880691ab957","repo":"alibaba/Sentinel","slug":"not-a-valid-rls-rule","errorCode":null,"errorMessage":"Not a valid RLS rule","messagePattern":"Not a valid RLS rule","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sentinel-cluster/sentinel-cluster-server-envoy-rls/src/main/java/com/alibaba/csp/sentinel/cluster/server/envoy/rls/rule/EnvoySentinelRuleConverter.java","lineNumber":46,"sourceCode":" * @author Eric Zhao\n * @since 1.7.0\n */\npublic final class EnvoySentinelRuleConverter {\n\n    /**\n     * Currently we use \"|\" to separate each key/value entries.\n     */\n    public static final String SEPARATOR = \"|\";\n\n    /**\n     * Convert the {@link EnvoyRlsRule} to a list of Sentinel flow rules.\n     *\n     * @param rule a valid Envoy RLS rule\n     * @return converted rules\n     */\n    public static List<FlowRule> toSentinelFlowRules(EnvoyRlsRule rule) {\n        if (!EnvoyRlsRuleManager.isValidRule(rule)) {\n            throw new IllegalArgumentException(\"Not a valid RLS rule\");\n        }\n        return rule.getDescriptors().stream()\n            .map(e -> toSentinelFlowRule(rule.getDomain(), e))\n            .collect(Collectors.toList());\n    }\n\n    public static FlowRule toSentinelFlowRule(String domain, EnvoyRlsRule.ResourceDescriptor descriptor) {\n        // One descriptor could have only one rule.\n        String identifier = generateKey(domain, descriptor);\n        long flowId = generateFlowId(identifier);\n        return new FlowRule(identifier)\n            .setCount(descriptor.getCount())\n            .setClusterMode(true)\n            .setClusterConfig(new ClusterFlowConfig()\n                .setFlowId(flowId)\n                .setThresholdType(ClusterRuleConstant.FLOW_THRESHOLD_GLOBAL)\n                .setSampleCount(1)\n                .setFallbackToLocalWhenFail(false));","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-cluster/sentinel-cluster-server-envoy-rls/src/main/java/com/alibaba/csp/sentinel/cluster/server/envoy/rls/rule/EnvoySentinelRuleConverter.java#L28-L64","documentation":"EnvoySentinelRuleConverter.toSentinelFlowRules() converts an EnvoyRlsRule into Sentinel FlowRules; first it validates the rule via EnvoyRlsRuleManager.isValidRule (domain non-empty and descriptors non-empty). Failing validation it throws IllegalArgumentException('Not a valid RLS rule') — the loaded YAML does not contain the required fields.","triggerScenarios":"Feeding an EnvoyRlsRule with null/blank domain or null/empty descriptors list; YAML structurally parseable but missing 'domain:' or 'descriptors:' keys (or descriptors: with no entries).","commonSituations":"Hand-writing the RLS YAML and omitting the domain; a descriptors block with only comments/empty list; YAML indentation making descriptors parse as part of another key; empty config file.","solutions":["Ensure the YAML has a non-empty 'domain' and at least one entry under 'descriptors'","Check indentation so descriptors is a top-level list of the rule","Add a startup validation/lint step for the rule file, or unit-test EnvoySentinelRuleConverter.toSentinelFlowRules on the config","Example minimal rule: domain: foo\\ndescriptors:\\n  - key: userId\\n    value: '1'\\n    count: 10"],"exampleFix":"# before (invalid)\ndomain: \"\"\ndescriptors: []\n\n# after (valid)\ndomain: my-service\ndescriptors:\n  - key: userId\n    value: \"1001\"\n    tokensPerFill: 10\n    fillInterval: 1s","handlingStrategy":"validation","validationCode":"EnvoyRlsRule rule = yaml.loadAs(text, EnvoyRlsRule.class);\nif (rule == null || StringUtil.isBlank(rule.getDomain())\n        || rule.getDescriptors() == null || rule.getDescriptors().isEmpty()) {\n    throw new IllegalArgumentException(\"RLS rule YAML must define domain and at least one descriptor\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint the RLS YAML in CI before deploying to the RLS server","Start from a known-good example rule and keep descriptors a top-level list"],"tags":["envoy","rls","rule-conversion","yaml","illegal-argument"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}