{"record":{"id":"f5161c1ebc549661","repo":"kestra-io/kestra","slug":"the-dayofweek-function-expects-a-date-argume","errorCode":null,"errorMessage":"The 'dayOfWeek()' function expects a 'date' argument.","messagePattern":"The 'dayOfWeek\\(\\)' function expects a 'date' argument\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfWeekFunction.java","lineNumber":41,"sourceCode":" * <p>\n * Usage: {@code {{ dayOfWeek(date) }}}\n *\n * <p>\n * Note: the day name is derived from the local date component of the input string;\n * no UTC normalization is performed. A datetime string such as {@code \"2025-01-06T00:30:00+02:00\"}\n * yields {@code \"MONDAY\"} (Jan 6), not {@code \"SUNDAY\"} (Jan 5 in UTC).\n *\n * @param date any valid ISO 8601 date or datetime string\n */\npublic class DayOfWeekFunction implements KestraFunction {\n    public static final String NAME = \"dayOfWeek\";\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 'dayOfWeek()' 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 'dayOfWeek()' function could not parse 'date': \" + e.getMessage(), lineNumber, self.getName());\n        }\n\n        return localDate.getDayOfWeek().name();\n    }\n\n    @Override\n    public List<String> getArgumentNames() {\n        return List.of(\"date\");\n    }\n\n    @Override","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfWeekFunction.java#L23-L59","documentation":"The dayOfWeek() function returns the day-of-week name (e.g. 'MONDAY') of an ISO 8601 date/datetime. It throws when the 'date' argument is null/absent (args.get(\"date\") == null). This is the missing-argument variant, distinct from the parse-failure variant.","triggerScenarios":"Calling {{ dayOfWeek() }} with no argument, or {{ dayOfWeek(undefinedVar) }} where the variable resolves to null.","commonSituations":"Omitting the date argument; binding to an optional output that is null; argument-name typo.","solutions":["Pass a valid date argument: {{ dayOfWeek(date=execution.startDate) }}.","Provide a fallback: {{ dayOfWeek(myDate ?? '2024-01-01') }}.","Ensure the upstream variable that feeds date is populated."],"exampleFix":"// before\n{{ dayOfWeek() }}\n// after\n{{ dayOfWeek(date=execution.startDate) }}","handlingStrategy":"validation","validationCode":"{{ dayOfWeek(date=(myDate ?? execution.startDate)) }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a non-null date argument.","Fall back to a known date when the source is optional.","Confirm the variable is populated before use."],"tags":["pebble","function","date","argument"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}