apache/skywalking · error · IllegalArgumentException

{funcName}() requires exactly 1 argument, got {argCount}

Error message

{funcName}() requires exactly 1 argument, got {argCount}

What it means

Thrown by TimeBucket.getTimestamp(long) when the argument matches none of the recognized time-bucket shapes. A timeBucket is a digit-packed long (yyyyMMddHHmmss for second, yyyyMMddHHmm for minute, yyyyMMddHH for hour, yyyyMMdd for day); the method infers the precision by numeric range checks and rejects anything outside all of them.

Source

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

    static void generateDefStatement(final StringBuilder sb,
                                      final LALScriptModel.DefStatement def,
                                      final LALClassGenerator.GenCtx genCtx) {
        final LALScriptModel.ValueAccess init = def.getInitializer();
        final String varName = def.getVarName();
        final String javaVar = "_def_" + varName;
        final boolean alreadyDeclared = genCtx.localVars.containsKey(varName);

        // Determine type and generate initializer expression
        Class<?> resolvedType;
        final StringBuilder initExpr = new StringBuilder();

        if (init.getFunctionCallName() != null
                && LALBlockCodegen.BUILTIN_FUNCTIONS.containsKey(init.getFunctionCallName())) {
            // Built-in function: toJson(...), toJsonArray(...)
            final String funcName = init.getFunctionCallName();
            final int argCount = init.getFunctionCallArgs().size();
            if (argCount != 1) {
                throw new IllegalArgumentException(
                    funcName + "() requires exactly 1 argument, got " + argCount);
            }
            final Object[] info = LALBlockCodegen.BUILTIN_FUNCTIONS.get(funcName);
            final String helperMethod = (String) info[0];
            resolvedType = (Class<?>) info[1];

            initExpr.append(helperMethod).append("(");
            LALValueCodegen.generateValueAccess(initExpr,
                init.getFunctionCallArgs().get(0).getValue(), genCtx);
            initExpr.append(")");
        } else {
            // General value access — type inferred from lastResolvedType
            LALValueCodegen.generateValueAccess(initExpr, init, genCtx);
            resolvedType = genCtx.lastResolvedType != null
                ? genCtx.lastResolvedType : Object.class;
            // Box primitive types for local variable declarations
            if (resolvedType.isPrimitive()) {
                final String boxName = LALCodegenHelper.boxTypeName(resolvedType);

View on GitHub (pinned to 102af09b4a)

Solutions

  1. Check the value with TimeBucket.isSecondBucket/isMinuteBucket/isHourBucket/isDayBucket before calling getTimestamp
  2. If you hold an epoch timestamp, build the bucket with TimeBucket.getTimeBucket(ms, DownSampling.Minute) instead
  3. Log/inspect the offending long — its digit count (13-14 = second, 12 = minute, 10 = hour, 8 = day) tells you which pipeline produced it

Example fix

// before
long ts = TimeBucket.getTimestamp(input); // throws on malformed input
// after
if (!TimeBucket.isSecondBucket(input) && !TimeBucket.isMinuteBucket(input)
        && !TimeBucket.isHourBucket(input) && !TimeBucket.isDayBucket(input)) {
    throw new IllegalArgumentException("malformed timeBucket: " + input);
}
long ts = TimeBucket.getTimestamp(input);
Defensive patterns

Strategy: validation

Validate before calling

boolean wellFormed = TimeBucket.isSecondBucket(b) || TimeBucket.isMinuteBucket(b)
    || TimeBucket.isHourBucket(b) || TimeBucket.isDayBucket(b);

Prevention

When it happens

Trigger: Calling TimeBucket.getTimestamp(bucket) with a value that is not a valid packed bucket: a raw epoch millis timestamp, a truncated/zero value, or a day bucket like 20240711 (which is below the minute range and only valid if isDayBucket accepts it — values outside 10_000_000_000_000..99_999_999_999_999 and the other range windows throw).

Common situations: Passing epoch milliseconds where a timeBucket long was expected; reading a corrupt or empty time_bucket column from storage; arithmetic that truncated a bucket (e.g. dividing a minute bucket incorrectly) before the call.

Related errors


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