{"record":{"id":"d86e2f4b277e06b3","repo":"apache/skywalking","slug":"unsupported-extractor-statement-in-lal-rule-at-lin","errorCode":null,"errorMessage":"Unsupported extractor statement in LAL rule at line {sourceLine}: {sourceText}","messagePattern":"Unsupported extractor statement in LAL rule at line (.+?): (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALScriptParser.java","lineNumber":273,"sourceCode":"            return visitTagStatement(ctx.tagStatement()).withSource(sourceLine, sourceText);\n        }\n        if (ctx.metricsBlock() != null) {\n            return visitMetricsBlock(ctx.metricsBlock()).withSource(sourceLine, sourceText);\n        }\n        if (ctx.outputFieldStatement() != null) {\n            return visitOutputFieldStatement(ctx.outputFieldStatement())\n                .withSource(sourceLine, sourceText);\n        }\n        // ifStatement carries its own per-branch line info; surface the if-line\n        // here for the surrounding statement-level capture.\n        if (ctx.ifStatement() != null) {\n            return (ExtractorStatement) visitIfStatement(ctx.ifStatement());\n        }\n        // Every alternative in the grammar's extractorStatement rule must have a branch above.\n        // Falling through used to run visitIfStatement(null), which threw a NullPointerException\n        // naming IfStatementContext — for a rule line containing no `if`, telling the author\n        // nothing. That is how segmentId and spanId stayed unimplemented without anyone noticing.\n        throw new IllegalArgumentException(\n            \"Unsupported extractor statement in LAL rule at line \" + sourceLine + \": \" + sourceText);\n    }\n\n    /**\n     * Verbatim source text of an ANTLR rule context — pulls from the original\n     * input stream rather than re-concatenating tokens, so whitespace inside\n     * the statement is preserved (matters for the dsl-debugging UI rendering\n     * {@code \"line N: <verbatim>\"}).\n     */\n    private static String rawTextOf(final ParserRuleContext ctx) {\n        if (ctx.getStart() == null || ctx.getStop() == null) {\n            return \"\";\n        }\n        return ctx.getStart().getInputStream().getText(\n            Interval.of(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex()));\n    }\n\n    private static FieldAssignment visitFieldAssignment(","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALScriptParser.java#L255-L291","documentation":"Thrown by MeterEntity.id() when the entity's scopeType is not one of the seven meter-supported scopes handled in the switch: SERVICE, SERVICE_INSTANCE, ENDPOINT, PROCESS, SERVICE_RELATION, PROCESS_RELATION, SERVICE_INSTANCE_RELATION. MeterEntity must translate its scope into an IDManager-built entity id; scope types with no id-building rule (e.g. SERVICE_INSTANCE_CLONE or future enum constants) cannot produce an id.","triggerScenarios":"Building a MeterEntity via newService/... factory then calling id() after manually setting an unsupported scope type; a MAL rule declaring a metric on a scope the meter system cannot address, routed into MeterEntity.id().","commonSituations":"Writing a custom MAL function or meter receiver that constructs MeterEntity for an unsupported ScopeType; extending ScopeType with new constants without extending MeterEntity.id(); reflective mutation of the private scopeType field.","solutions":["Create MeterEntity through its factory methods (newService, newServiceInstance, newEndpoint, newProcess, relation variants) so scopeType and fields stay consistent","Restrict MAL metric scope declarations to the supported scope types","If you added a ScopeType, add the corresponding IDManager case to MeterEntity.id()"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"java.util.Set<ScopeType> METER_SCOPES = java.util.EnumSet.of(ScopeType.SERVICE, ScopeType.SERVICE_INSTANCE,\n    ScopeType.ENDPOINT, ScopeType.PROCESS, ScopeType.SERVICE_RELATION,\n    ScopeType.PROCESS_RELATION, ScopeType.SERVICE_INSTANCE_RELATION);\nif (!METER_SCOPES.contains(entity.getScopeType())) throw new IllegalArgumentException(\"unsupported meter scope\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build MeterEntity only through its static factory methods","Restrict MAL rules to meter-supported scopes"],"tags":["skywalking","oap","meter","scope","mal"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}