{"record":{"id":"bdc0d54a131e9585","repo":"apache/skywalking","slug":"mal-rule-layerdefinitions-entry-rejected","errorCode":null,"errorMessage":"MAL rule {} layerDefinitions entry rejected: {}","messagePattern":"MAL rule (.+?) layerDefinitions entry rejected: (.+?)","errorType":"exception","errorClass":"UnexpectedException","httpStatus":null,"severity":"error","filePath":"oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/prometheus/rule/Rules.java","lineNumber":187,"sourceCode":"        }\n    }\n\n    /**\n     * Funnel any inline {@code layerDefinitions:} entries through {@code Layer.register}.\n     * Conflict checks (reserved-range, name uniqueness, ordinal uniqueness, sealed-state) live\n     * in {@code Layer.register}; failures here surface with the offending rule name in\n     * the stack trace.\n     */\n    private static void registerInlineLayers(final String ruleName, final Rule rule) {\n        final List<LayerDefinition> defs = rule.getLayerDefinitions();\n        if (defs == null || defs.isEmpty()) {\n            return;\n        }\n        for (final LayerDefinition def : defs) {\n            try {\n                def.register();\n            } catch (RuntimeException e) {\n                throw new UnexpectedException(\n                    \"MAL rule \" + ruleName + \" layerDefinitions entry rejected: \" + def, e);\n            }\n        }\n    }\n}\n","sourceCodeStart":169,"sourceCodeEnd":193,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/prometheus/rule/Rules.java#L169-L193","documentation":"UnexpectedException thrown when an inline 'layerDefinitions:' entry in a MAL rule is rejected by Layer.register — the central gatekeeper for layer registration. register() enforces reserved ordinal ranges, name uniqueness, ordinal uniqueness, and the sealed state of the layer registry; any RuntimeException from it is re-thrown with the offending rule name and the layer definition string.","triggerScenarios":"A rule YAML declares layerDefinitions whose 'name' already exists, whose 'value' (ordinal) collides with an existing layer, or whose ordinal falls inside a reserved range; also when the layer registry has been sealed (rules load after boot-time sealing) so no new registrations are accepted. The full definition and cause are in the exception chain.","commonSituations":"Two custom rules both defining a layer with the same name or ordinal; copying a rule file and editing the layer name but not the ordinal; defining a layer in the 9000+ (or otherwise reserved) ordinal range; layer conflicts between an inline definition and layers registered from the UI/API layer endpoint.","solutions":["Read the wrapped cause from Layer.register — it states the exact conflict (duplicate name, duplicate ordinal, reserved range, or sealed registry)","Change the layer name and/or ordinal in the rule's layerDefinitions so they are globally unique and outside reserved ranges","If a layer with that name is already registered (e.g. created via UI), remove the inline definition and reference the existing layer instead","If the registry is sealed, move the layerDefinition to a rule that loads before sealing, or register the layer through the supported config path"],"exampleFix":"# before\nlayerDefinitions:\n  - name: custom-layer\n    value: 9000   # reserved range collision\n# after\nlayerDefinitions:\n  - name: custom-layer\n    value: 7000","handlingStrategy":"validation","validationCode":"// Before registering: check uniqueness against the Layer registry you target\nOptional<Layer> clashName = Layer.ALL.values().stream().filter(l -> l.name().equals(def.getName())).findAny();\nOptional<Layer> clashOrdinal = Layer.ALL.values().stream().filter(l -> l.ordinal() == def.getValue()).findAny();\nif (clashName.isPresent() || clashOrdinal.isPresent()) throw new IllegalStateException(\"layer conflict\");","typeGuard":null,"tryCatchPattern":"catch (UnexpectedException e) { /* message names the rule + def; cause says which Layer.register rule failed */ }","preventionTips":["Keep a single authoritative table of custom layer names/ordinals across all rules","Avoid reserved ordinal ranges documented for built-in layers","Don't define layers inline in more than one rule"],"tags":["mal","layer","rule-config","conflict","startup"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}