kestra-io/kestra · error · PebbleException

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

Error message

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

What it means

The isWeekend(date) Pebble function requires a 'date' argument. If the args map does not contain a 'date' key (or its value is null), the function throws immediately before any parsing is attempted. This is a usage/contract error, not a data-format error.

Source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/IsWeekendFunction.java:32

import io.pebbletemplates.pebble.template.PebbleTemplate;

/**
 * Pebble function that returns {@code true} if the given date falls on Saturday or Sunday.
 *
 * <p>
 * Usage: {@code {{ isWeekend(date) }}}
 *
 * @param date any valid ISO 8601 date or datetime string
 */
public class IsWeekendFunction implements KestraFunction {
    public static final String NAME = "isWeekend";

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

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

        DayOfWeek dayOfWeek = localDate.getDayOfWeek();
        return dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY;
    }

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

View on GitHub (pinned to 823fada927)

Solutions

  1. Supply a non-null 'date' argument: {{ isWeekend('2024-01-15') }} or {{ isWeekend(myDateVar) }} where myDateVar is guaranteed non-null.
  2. If the date may be null, guard with a Pebble conditional: {% if myDateVar is not null %}{{ isWeekend(myDateVar) }}{% endif %}.

Example fix

# before
value: "{{ isWeekend() }}"
# after
value: "{{ isWeekend('2024-01-15') }}"
Defensive patterns

Strategy: validation

Validate before calling

# Guard against null before calling isWeekend:
{% if myDateVar is not null %}
  {{ isWeekend(myDateVar) }}
{% else %}
  {{ throw('isWeekend requires a non-null date') }}
{% endif %}

Prevention

When it happens

Trigger: Calling {{ isWeekend() }} with no arguments; calling {{ isWeekend(someVar) }} where someVar resolves to null at runtime; passing the argument under a wrong named parameter so 'date' is never set.

Common situations: The flow author passed a variable reference that is null because the upstream task has not produced the output yet. The author used a positional argument that Pebble did not map to the 'date' key.

Related errors


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