kestra-io/kestra · critical · PebbleException

The 'isDayWeekInMonth()' function expects a 'position' argum

Error message

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

What it means

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

Source

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

 * @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());
        } 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()

View on GitHub (pinned to 823fada927)

Solutions

  1. Pass a valid position keyword (FIRST, SECOND, THIRD, FOURTH, or LAST).
  2. Guard templated values before calling.

Example fix

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

Strategy: validation

Validate before calling

{% if myPosition is not empty %}{{ isDayWeekInMonth(date='2024-01-15', dayOfWeek='MONDAY', position=myPosition) }}{% endif %}

Prevention

When it happens

Trigger: Calling isDayWeekInMonth(date='2024-01-15', dayOfWeek='MONDAY') without position.

Common situations: Omitted argument, or a templated position that resolved to null.

Related errors


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