{"record":{"id":"2a69e5c310bbd551","repo":"kestra-io/kestra","slug":"the-randomin-function-expects-an-argument-s-o","errorCode":null,"errorMessage":"The 'randomIn()' function expects an argument %s of type Long.","messagePattern":"The 'randomIn\\(\\)' function expects an argument (.+?) of type Long\\.","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/RandomIntFunction.java","lineNumber":51,"sourceCode":"\n    @Override\n    public Map<String, String> getArgumentDefaults() {\n        return Map.of(\"lower\", \"0\", \"upper\", \"10\");\n    }\n\n    private Long getArgument(\n        Map<String, Object> args, String arg, PebbleTemplate self, int lineNumber) {\n        if (!args.containsKey(arg)) {\n            throw new PebbleException(\n                null,\n                \"The 'randomIn()' function expects an argument \" + arg,\n                lineNumber,\n                self.getName()\n            );\n        }\n\n        if (!(args.get(arg) instanceof Long)) {\n            throw new PebbleException(\n                null,\n                \"The 'randomIn()' function expects an argument \" + arg + \" of type Long.\",\n                lineNumber,\n                self.getName()\n            );\n        }\n        return (Long) args.get(arg);\n    }\n}\n","sourceCodeStart":33,"sourceCodeEnd":61,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/RandomIntFunction.java#L33-L61","documentation":"The randomInt(lower, upper) function checks that each argument value is an instance of Long. Pebble evaluates numeric literals as Long, so this fires when a non-numeric type is passed — a String, a Float/Double, or a Boolean. Note: the error message incorrectly references 'randomIn()' instead of 'randomInt()', and uses %s-style formatting with string concatenation.","triggerScenarios":"Passing a string: {{ randomInt(lower='0', upper='10') }}. Passing a float/double: {{ randomInt(lower=0.5, upper=10.5) }}. Passing a variable that holds a non-Long type.","commonSituations":"YAML values that Pebble evaluates as strings rather than numbers. An upstream task output provides a string representation of a number instead of a numeric type. The author passes a decimal where an integer is expected.","solutions":["Pass integer literals (Pebble evaluates them as Long): {{ randomInt(lower=0, upper=10) }}.","If the value comes from a variable that might be a string, convert it in the expression or ensure the upstream task outputs a numeric type.","Avoid decimal values — randomInt operates on integer ranges only."],"exampleFix":"# before\nvalue: \"{{ randomInt(lower='0', upper='10') }}\"\n# after\nvalue: \"{{ randomInt(lower=0, upper=10) }}\"","handlingStrategy":"type-guard","validationCode":"# Ensure arguments are integers (Long), not strings or decimals:\n{{ randomInt(lower=0, upper=10) }}\n# If from a variable, ensure it is numeric and integer-valued:\n{% if lowerVar is number and upperVar is number %}\n  {{ randomInt(lower=lowerVar, upper=upperVar) }}\n{% endif %}","typeGuard":"# Pebble type test for numeric values:\n{% if myVar is number %}...{% endif %}","tryCatchPattern":null,"preventionTips":["Pass integer literals directly — Pebble evaluates them as Long.","Avoid string or decimal values for lower/upper arguments.","Ensure upstream task outputs numeric types, not string representations of numbers."],"tags":["pebble-function","randomint","type-mismatch","error-message-bug"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}