apache/skywalking · error · IllegalArgumentException

Unknown identifier used as method argument: '{text}'

Error message

Unknown identifier used as method argument: '{text}'

What it means

Thrown at LAL compile time when an identifier appears as a method-call argument and matches none of the recognized forms: not a known literal type, not a def-declared local variable in genCtx.localVars, and not a value access (parsed/log ref, chain, function call, or parenthesized expression). It is the argument-position guard equivalent of the general 'no matching codegen path' error.

Source

Thrown at oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALValueCodegen.java:1770

                final String text = va.getSegments().get(0);
                if ("true".equals(text) || "false".equals(text)
                        || "null".equals(text)) {
                    // Boolean or null literal
                    sb.append(text);
                } else if (genCtx != null
                        && genCtx.localVars.containsKey(text)) {
                    // Local def variable reference
                    sb.append(genCtx.localVars.get(text).javaVarName);
                } else if (genCtx != null
                        && (va.isParsedRef() || va.isLogRef()
                            || !va.getChain().isEmpty()
                            || va.getFunctionCallName() != null
                            || va.getParenInner() != null)) {
                    // tag(), parsed.*, log.*, paren-cast, or any value
                    // access with a chain — render via the standard path.
                    generateValueAccess(sb, va, genCtx);
                } else {
                    throw new IllegalArgumentException(
                        "Unknown identifier used as method argument: '" + text + "'");
                }
            } else {
                sb.append("null");
            }
        }
        return sb.toString();
    }
}

View on GitHub (pinned to 102af09b4a)

Solutions

  1. Declare the identifier with def first, e.g. def data = parsed.payload, then use toJson(data)
  2. If it should be a string, quote it: toJson("literal")
  3. If it is a field of the input, qualify it: parsed.payload or log.body
  4. Move the def statement above the method call that consumes it

Example fix

# before
extractor {
  def obj = toJson(payload)
}

# after
extractor {
  def payload = parsed.payload
  def obj = toJson(payload)
}
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Method calls like toJsonArray(items) or toJson(data) where 'items'/'data' was never declared with def; using a variable declared inside a different block/rule; bare identifiers with no root qualifier.

Common situations: Forgetting the def declaration when refactoring a rule; referencing a def variable before its def statement in the generated method ordering; splitting a complex expression into helper variables but omitting one declaration.

Related errors


AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14). Data as JSON: /api/errors/4c948abb0bf1eac9. Report an issue: GitHub.