kestra-io/kestra · critical · PebbleException

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

Error message

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

What it means

The isDayWeekInMonth() function requires three arguments — date, dayOfWeek, position. This fires when date is null or missing.

Source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/IsDayWeekInMonthFunction.java:40

 * <ul>
 * <li>{@code {{ isDayWeekInMonth(date, dayOfWeek, position) }}}</li>
 * </ul>
 *
 * @param date any valid ISO 8601 date or datetime string
 * @param dayOfWeek day of the week (e.g. {@code "MONDAY"}, {@code "FRIDAY"})
 * @param position occurrence within the month: {@code FIRST}, {@code SECOND}, {@code THIRD}, {@code FOURTH}, or {@code LAST}
 */
public class IsDayWeekInMonthFunction implements KestraFunction {
    public static final String NAME = "isDayWeekInMonth";

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

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

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

        DayOfWeek dayOfWeek;
        try {
            dayOfWeek = DayOfWeek.valueOf(dayOfWeekArg.toString().toUpperCase());

View on GitHub (pinned to 823fada927)

Solutions

  1. Pass a valid ISO date string as date (e.g. isDayWeekInMonth(date='2024-01-15', dayOfWeek='MONDAY', position='FIRST')).
  2. Guard templated date values with 'is not empty' before calling.

Example fix

// before
{{ isDayWeekInMonth(dayOfWeek='MONDAY', position='FIRST') }}
// after
{{ isDayWeekInMonth(date='2024-01-15', dayOfWeek='MONDAY', position='FIRST') }}
Defensive patterns

Strategy: validation

Validate before calling

{% if myDate is not empty %}{{ isDayWeekInMonth(date=myDate, dayOfWeek='MONDAY', position='FIRST') }}{% endif %}

Prevention

When it happens

Trigger: Calling isDayWeekInMonth(dayOfWeek='MONDAY', position='FIRST') without a date, or with a date variable that resolved to null.

Common situations: Referencing an output that is not set, or positional misuse of the arguments.

Related errors


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