{"record":{"id":"6486a926e387f4a7","repo":"apache/skywalking","slug":"failed-to-compile-hierarchy-rule-name-expressi","errorCode":null,"errorMessage":"Failed to compile hierarchy rule: {name}, expression: {expression}","messagePattern":"Failed to compile hierarchy rule: (.+?), expression: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"oap-server/analyzer/hierarchy/src/main/java/org/apache/skywalking/oap/server/core/config/v2/compiler/CompiledHierarchyRuleProvider.java","lineNumber":76,"sourceCode":"    }\n\n    @Override\n    public Map<String, BiFunction<Service, Service, Boolean>> buildRules(\n            final Map<String, String> ruleExpressions,\n            final Map<String, Integer> ruleLines) {\n        final Map<String, BiFunction<Service, Service, Boolean>> rules = new HashMap<>();\n        ruleExpressions.forEach((name, expression) -> {\n            try {\n                // Per rule, not per file: the generator labels the class _L<line>_ and puts\n                // (file:line) in SourceFile, so a single file-level coordinate would give every\n                // hierarchy rule the same line.\n                final Integer line = ruleLines.get(name);\n                generator.setSourceRef(DslSourceRef.ofRule(\n                    HIERARCHY_RULE_FILE, line == null ? 0 : line));\n                rules.put(name, generator.compile(name, expression));\n                log.debug(\"Compiled hierarchy rule: {}\", name);\n            } catch (Exception e) {\n                throw new IllegalStateException(\n                    \"Failed to compile hierarchy rule: \" + name\n                        + \", expression: \" + expression, e);\n            }\n        });\n        return rules;\n    }\n}\n","sourceCodeStart":58,"sourceCodeEnd":84,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/analyzer/hierarchy/src/main/java/org/apache/skywalking/oap/server/core/config/v2/compiler/CompiledHierarchyRuleProvider.java#L58-L84","documentation":"Thrown by Layer.registerDynamic when the name is already registered with a different ordinal and/or isNormal flag. Registration is idempotent only when both value and isNormal match the existing entry; any mismatch is a conflict because layer ordinals are persisted in storage and a silent redefinition would corrupt historical data.","triggerScenarios":"Calling Layer.registerDynamic(\"MY_LAYER\", 100500, true) when MY_LAYER already exists with ordinal 100001 (or with isNormal=false). Happens when a runtime hot-update rule redefines a layer with changed attributes, or when two rule files claim the same name with different ordinals.","commonSituations":"Editing the ordinal in a layerDefinitions block and hot-reloading without restarting the OAP; two independent MAL/LAL runtime rules defining the same layer name differently; changing the isNormal flag of an existing layer.","solutions":["Align the new definition with the existing one: use the same ordinal and isNormal value already registered (the error message prints them)","If the change is intentional, restart the OAP with a clean definition rather than hot-reloading, and be aware ordinals already persisted in storage are frozen","Rename the new layer if it is genuinely a different layer"],"exampleFix":"// before — MY_LAYER already registered as ordinal=100001, normal=true\nLayer.registerDynamic(\"MY_LAYER\", 100500, true);\n// after\nLayer.registerDynamic(\"MY_LAYER\", 100001, true); // idempotent, returns existing","handlingStrategy":"validation","validationCode":"Layer existing = Layer.nameOf(name);\nboolean idempotent = existing == Layer.UNDEFINED\n    || (existing.value() == value && existing.isNormal() == isNormal);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep layer definitions stable across hot-reloads: same name -> same ordinal + isNormal","Restart instead of hot-reloading when intentionally changing a layer's identity"],"tags":["skywalking","oap","layer","conflict","configuration"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}