kestra-io/kestra · error · PebbleException

The 'randomIn()' function expects an argument %s

Error message

The 'randomIn()' function expects an argument %s

What it means

The randomInt(lower, upper) function checks that both arguments are present in the args map. If either 'lower' or 'upper' is missing, this error fires, naming the missing argument. Note: the error message incorrectly says 'randomIn()' instead of 'randomInt()'. Although defaults exist (lower=0, upper=10), this error only fires if the defaults mechanism does not populate the args map (e.g. explicit null override or a function invocation path that bypasses default injection).

Source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/RandomIntFunction.java:42

            );
        }
        return (int) (Math.floor(Math.random() * (upper - lower)) + lower);
    }

    @Override
    public List<String> getArgumentNames() {
        return List.of("lower", "upper");
    }

    @Override
    public Map<String, String> getArgumentDefaults() {
        return Map.of("lower", "0", "upper", "10");
    }

    private Long getArgument(
        Map<String, Object> args, String arg, PebbleTemplate self, int lineNumber) {
        if (!args.containsKey(arg)) {
            throw new PebbleException(
                null,
                "The 'randomIn()' function expects an argument " + arg,
                lineNumber,
                self.getName()
            );
        }

        if (!(args.get(arg) instanceof Long)) {
            throw new PebbleException(
                null,
                "The 'randomIn()' function expects an argument " + arg + " of type Long.",
                lineNumber,
                self.getName()
            );
        }
        return (Long) args.get(arg);
    }
}

View on GitHub (pinned to 823fada927)

Solutions

  1. Provide both arguments explicitly: {{ randomInt(lower=0, upper=10) }}.
  2. Call {{ randomInt() }} with no arguments to use the built-in defaults of lower=0, upper=10.

Example fix

# before
value: "{{ randomInt(upper=null) }}"
# after
value: "{{ randomInt(lower=0, upper=10) }}"
Defensive patterns

Strategy: validation

Validate before calling

# Provide both arguments explicitly, or call with no args for defaults:
{{ randomInt(lower=0, upper=10) }}
# or simply:
{{ randomInt() }}

Prevention

When it happens

Trigger: Explicitly passing null for one argument: {{ randomInt(lower=5, upper=null) }}. A function invocation path where defaults are not applied.

Common situations: The defaults (lower=0, upper=10) normally cover the common case, so this error is rare in practice. It can surface in programmatic template rendering or when arguments are explicitly set to null.

Related errors


AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14). Data as JSON: /api/errors/4a14696b9fa25d91. Report an issue: GitHub.