{"record":{"id":"de3faf776a77e42d","repo":"apache/skywalking","slug":"hierarchy-rule-parsing-failed-errors-in-express","errorCode":null,"errorMessage":"Hierarchy rule parsing failed: {errors} in expression: {expression}","messagePattern":"Hierarchy rule parsing failed: (.+?) in expression: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"oap-server/analyzer/hierarchy/src/main/java/org/apache/skywalking/oap/server/core/config/v2/compiler/HierarchyRuleScriptParser.java","lineNumber":66,"sourceCode":"        final HierarchyRuleParser parser = new HierarchyRuleParser(tokens);\n\n        final List<String> errors = new ArrayList<>();\n        parser.removeErrorListeners();\n        parser.addErrorListener(new BaseErrorListener() {\n            @Override\n            public void syntaxError(final Recognizer<?, ?> recognizer,\n                                    final Object offendingSymbol,\n                                    final int line,\n                                    final int charPositionInLine,\n                                    final String msg,\n                                    final RecognitionException e) {\n                errors.add(line + \":\" + charPositionInLine + \" \" + msg);\n            }\n        });\n\n        final HierarchyRuleParser.MatchingRuleContext tree = parser.matchingRule();\n        if (!errors.isEmpty()) {\n            throw new IllegalArgumentException(\n                \"Hierarchy rule parsing failed: \" + String.join(\"; \", errors)\n                    + \" in expression: \" + expression);\n        }\n\n        return new HierarchyRuleModelVisitor().visit(tree);\n    }\n\n    /**\n     * Visitor that transforms the ANTLR4 parse tree into {@link HierarchyRuleModel}.\n     */\n    private static final class HierarchyRuleModelVisitor\n            extends HierarchyRuleParserBaseVisitor<HierarchyRuleModel> {\n\n        @Override\n        public HierarchyRuleModel visitMatchingRule(final HierarchyRuleParser.MatchingRuleContext ctx) {\n            final String upperParam = ctx.param(0).getText();\n            final String lowerParam = ctx.param(1).getText();\n            final HierarchyRuleModel.RuleBody body = convertRuleBody(ctx.ruleBody());","sourceCodeStart":48,"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/HierarchyRuleScriptParser.java#L48-L84","documentation":"Thrown by Layer.registerDynamic when a different layer name already occupies the requested ordinal. Ordinals are the persisted identity of a layer (storage rows reference the int), so two names on one ordinal are never allowed, even if attributes otherwise match.","triggerScenarios":"Calling Layer.registerDynamic(\"NEW_LAYER\", 100001, true) when ordinal 100001 belongs to ANOTHER_LAYER. Typical cause: copy-pasting a layerDefinitions entry and changing only the name, keeping the ordinal.","commonSituations":"Duplicating an existing layer definition block in a runtime MAL/LAL file and forgetting to bump the ordinal; hardcoded ordinal sequences that drift between environments.","solutions":["Assign a fresh unused ordinal >= 100000 to the new layer (the error prints the existing owner name)","If the same layer is intended, reuse the existing name so the idempotent path in registerDynamic returns it","Keep a documented allocation table for dynamic-layer ordinals to avoid collisions between rule files"],"exampleFix":"# before — ordinal 100001 already used by OTHER_LAYER\nlayerDefinitions:\n  - name: NEW_LAYER\n    ordinal: 100001\n# after\nlayerDefinitions:\n  - name: NEW_LAYER\n    ordinal: 100002","handlingStrategy":"validation","validationCode":"boolean ordinalFree = java.util.Arrays.stream(Layer.values()).noneMatch(l -> l.value() == value);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain an ordinal allocation table per deployment","When copying a layerDefinitions block, always change both name AND ordinal"],"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"}