{"record":{"id":"4a14696b9fa25d91","repo":"kestra-io/kestra","slug":"the-randomin-function-expects-an-argument-s","errorCode":null,"errorMessage":"The 'randomIn()' function expects an argument %s","messagePattern":"The 'randomIn\\(\\)' function expects an argument (.+?)","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/RandomIntFunction.java","lineNumber":42,"sourceCode":"            );\n        }\n        return (int) (Math.floor(Math.random() * (upper - lower)) + lower);\n    }\n\n    @Override\n    public List<String> getArgumentNames() {\n        return List.of(\"lower\", \"upper\");\n    }\n\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}","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/RandomIntFunction.java#L24-L60","documentation":"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).","triggerScenarios":"Explicitly passing null for one argument: {{ randomInt(lower=5, upper=null) }}. A function invocation path where defaults are not applied.","commonSituations":"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.","solutions":["Provide both arguments explicitly: {{ randomInt(lower=0, upper=10) }}.","Call {{ randomInt() }} with no arguments to use the built-in defaults of lower=0, upper=10."],"exampleFix":"# before\nvalue: \"{{ randomInt(upper=null) }}\"\n# after\nvalue: \"{{ randomInt(lower=0, upper=10) }}\"","handlingStrategy":"validation","validationCode":"# Provide both arguments explicitly, or call with no args for defaults:\n{{ randomInt(lower=0, upper=10) }}\n# or simply:\n{{ randomInt() }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call randomInt() with no arguments to use defaults (lower=0, upper=10).","Never explicitly pass null for either argument.","Lint Pebble expressions to ensure required arguments are present."],"tags":["pebble-function","randomint","missing-argument","error-message-bug"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}