{"record":{"id":"0c63c2812fcbac78","repo":"kestra-io/kestra","slug":"the-isweekend-function-expects-a-date-argume","errorCode":null,"errorMessage":"The 'isWeekend()' function expects a 'date' argument.","messagePattern":"The 'isWeekend\\(\\)' function expects a 'date' argument\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/IsWeekendFunction.java","lineNumber":32,"sourceCode":"import io.pebbletemplates.pebble.template.PebbleTemplate;\n\n/**\n * Pebble function that returns {@code true} if the given date falls on Saturday or Sunday.\n *\n * <p>\n * Usage: {@code {{ isWeekend(date) }}}\n *\n * @param date any valid ISO 8601 date or datetime string\n */\npublic class IsWeekendFunction implements KestraFunction {\n    public static final String NAME = \"isWeekend\";\n\n    @Override\n    public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {\n        Object dateArg = args.get(\"date\");\n\n        if (dateArg == null) {\n            throw new PebbleException(null, \"The 'isWeekend()' function expects a 'date' argument.\", lineNumber, self.getName());\n        }\n\n        LocalDate localDate;\n        try {\n            localDate = DateUtils.parseLocalDate(dateArg.toString());\n        } catch (InternalException e) {\n            throw new PebbleException(e, \"The 'isWeekend()' function could not parse 'date': \" + e.getMessage(), lineNumber, self.getName());\n        }\n\n        DayOfWeek dayOfWeek = localDate.getDayOfWeek();\n        return dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY;\n    }\n\n    @Override\n    public List<String> getArgumentNames() {\n        return List.of(\"date\");\n    }\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/IsWeekendFunction.java#L14-L50","documentation":"The isWeekend(date) Pebble function requires a 'date' argument. If the args map does not contain a 'date' key (or its value is null), the function throws immediately before any parsing is attempted. This is a usage/contract error, not a data-format error.","triggerScenarios":"Calling {{ isWeekend() }} with no arguments; calling {{ isWeekend(someVar) }} where someVar resolves to null at runtime; passing the argument under a wrong named parameter so 'date' is never set.","commonSituations":"The flow author passed a variable reference that is null because the upstream task has not produced the output yet. The author used a positional argument that Pebble did not map to the 'date' key.","solutions":["Supply a non-null 'date' argument: {{ isWeekend('2024-01-15') }} or {{ isWeekend(myDateVar) }} where myDateVar is guaranteed non-null.","If the date may be null, guard with a Pebble conditional: {% if myDateVar is not null %}{{ isWeekend(myDateVar) }}{% endif %}."],"exampleFix":"# before\nvalue: \"{{ isWeekend() }}\"\n# after\nvalue: \"{{ isWeekend('2024-01-15') }}\"","handlingStrategy":"validation","validationCode":"# Guard against null before calling isWeekend:\n{% if myDateVar is not null %}\n  {{ isWeekend(myDateVar) }}\n{% else %}\n  {{ throw('isWeekend requires a non-null date') }}\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide the date argument positionally or by name.","Use Pebble 'is not null' guards for variables that may be absent.","Verify upstream tasks produce the expected output before referencing them in function calls."],"tags":["pebble-function","missing-argument","isweekend"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}