kestra-io/kestra · error · PebbleException

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

Error message

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

What it means

The dayOfMonth() Pebble function returns the day of the month (1-31) of an ISO 8601 date/datetime string. It throws when the 'date' argument is absent/null (args.get("date") == null). This is a missing-argument error, not a parse error.

Source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfMonthFunction.java:31

import io.pebbletemplates.pebble.template.PebbleTemplate;

/**
 * Pebble function that returns the day of the month (1–31) of the given date.
 *
 * <p>
 * Usage: {@code {{ dayOfMonth(date) }}}
 *
 * @param date any valid ISO 8601 date or datetime string
 */
public class DayOfMonthFunction implements KestraFunction {
    public static final String NAME = "dayOfMonth";

    @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 'dayOfMonth()' function expects a 'date' argument.", lineNumber, self.getName());
        }

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

        return localDate.getDayOfMonth();
    }

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

    @Override

View on GitHub (pinned to 823fada927)

Solutions

  1. Pass a valid date argument: {{ dayOfMonth(trigger.date) }} or {{ dayOfMonth('2024-01-15') }}.
  2. Provide a fallback date: {{ dayOfMonth(myDate ?? execution.startDate) }}.
  3. Ensure the variable feeding date is set by the upstream task.

Example fix

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

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Calling {{ dayOfMonth() }} with no argument, or {{ dayOfMonth(missing) }} where 'missing' is undefined/null.

Common situations: Forgetting to pass a date; binding date to an optional output that is null for this run; typo in the argument name.

Related errors


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