kestra-io/kestra · error · PebbleException

The 'dayOfWeek()' function expects a 'date' argument.

Error message

The 'dayOfWeek()' function expects a 'date' argument.

What it means

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.

Source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfWeekFunction.java:41

 * <p>
 * Usage: {@code {{ dayOfWeek(date) }}}
 *
 * <p>
 * Note: the day name is derived from the local date component of the input string;
 * no UTC normalization is performed. A datetime string such as {@code "2025-01-06T00:30:00+02:00"}
 * yields {@code "MONDAY"} (Jan 6), not {@code "SUNDAY"} (Jan 5 in UTC).
 *
 * @param date any valid ISO 8601 date or datetime string
 */
public class DayOfWeekFunction implements KestraFunction {
    public static final String NAME = "dayOfWeek";

    @Override
    public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {
        Object dateArg = args.get("date");

        if (dateArg == null) {
            throw new PebbleException(null, "The 'dayOfWeek()' function expects a 'date' argument.", lineNumber, self.getName());
        }

        LocalDate localDate;
        try {
            localDate = DateUtils.parseLocalDate(dateArg.toString());
        } catch (InternalException e) {
            throw new PebbleException(e, "The 'dayOfWeek()' function could not parse 'date': " + e.getMessage(), lineNumber, self.getName());
        }

        return localDate.getDayOfWeek().name();
    }

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

    @Override

View on GitHub (pinned to 823fada927)

Solutions

  1. Pass a valid date argument: {{ dayOfWeek(date=execution.startDate) }}.
  2. Provide a fallback: {{ dayOfWeek(myDate ?? '2024-01-01') }}.
  3. Ensure the upstream variable that feeds date is populated.

Example fix

// before
{{ dayOfWeek() }}
// after
{{ dayOfWeek(date=execution.startDate) }}
Defensive patterns

Strategy: validation

Validate before calling

{{ dayOfWeek(date=(myDate ?? execution.startDate)) }}

Prevention

When it happens

Trigger: Calling {{ dayOfWeek() }} with no argument, or {{ dayOfWeek(undefinedVar) }} where the variable resolves to null.

Common situations: Omitting the date argument; binding to an optional output that is null; argument-name typo.

Related errors


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