kestra-io/kestra · error · PebbleException

The 'isDayWeekInMonth()' function received an invalid 'dayOf

Error message

The 'isDayWeekInMonth()' function received an invalid 'dayOfWeek' value: '{dayOfWeekArg}'. Expected one of: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY.

What it means

The dayOfWeek argument must be one of MONDAY…SUNDAY (case-insensitive). DayOfWeek.valueOf threw, so the value did not match an enum constant.

Source

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

        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());
        } catch (IllegalArgumentException e) {
            throw new PebbleException(
                e,
                "The 'isDayWeekInMonth()' function received an invalid 'dayOfWeek' value: '" + dayOfWeekArg
                    + "'. Expected one of: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY.",
                lineNumber, self.getName()
            );
        }

        LocalDate computed = switch (positionArg.toString().toUpperCase()) {
            case "FIRST" -> localDate.with(TemporalAdjusters.firstInMonth(dayOfWeek));
            case "SECOND" -> localDate.with(TemporalAdjusters.firstInMonth(dayOfWeek)).plusWeeks(1);
            case "THIRD" -> localDate.with(TemporalAdjusters.firstInMonth(dayOfWeek)).plusWeeks(2);
            case "FOURTH" -> localDate.with(TemporalAdjusters.firstInMonth(dayOfWeek)).plusWeeks(3);
            case "LAST" -> localDate.with(TemporalAdjusters.lastInMonth(dayOfWeek));
            default -> throw new PebbleException(
                null, "The 'isDayWeekInMonth()' function received an invalid 'position' value: '" + positionArg + "'. Expected one of: FIRST, SECOND, THIRD, FOURTH, LAST.", lineNumber,
                self.getName()
            );
        };

View on GitHub (pinned to 823fada927)

Solutions

  1. Use the full uppercase day name: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY.
  2. If the value comes from a variable, upper-case it: dayOfWeek=myVar|upper.

Example fix

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

Strategy: validation

Validate before calling

{% set d = dayOfWeek|upper %}{% if d in ['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY'] %}{{ isDayWeekInMonth(date=myDate, dayOfWeek=d, position='FIRST') }}{% endif %}

Type guard

{% macro is_valid_day(d) %}{{ d|upper in ['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY'] }}{% endmacro %}

Prevention

When it happens

Trigger: Passing dayOfWeek='MON' (3-letter abbreviation), 'Wed' (mixed case, abbreviated), 'Wednesday' is fine in full uppercase, but 'WED' or a typo is not.

Common situations: Using 3-letter abbreviations or full lower-case/mixed-case words instead of the uppercase full enum name.

Related errors


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