kestra-io/kestra · error · PebbleException

The 'isLastWorkingDay()' function could not parse 'date': {e

Error message

The 'isLastWorkingDay()' function could not parse 'date': {e.getMessage()}

What it means

isLastWorkingDay() could not parse the date argument with DateUtils.parseLocalDate; the value is not a recognizable ISO 8601 date or datetime. The wrapped InternalException message gives the parse detail.

Source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/IsLastWorkingDayFunction.java:56

    private static final Set<DayOfWeek> DEFAULT_WORKING_DAYS = EnumSet.of(
        DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY,
        DayOfWeek.THURSDAY, DayOfWeek.FRIDAY
    );

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

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

        Set<DayOfWeek> workingDays = resolveWorkingDays(args.get("workingDays"), self, lineNumber);

        if (!workingDays.contains(localDate.getDayOfWeek())) {
            return false;
        }

        // Walk backwards from the last calendar day of the month to find the last working day
        LocalDate lastOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth());
        LocalDate candidate = lastOfMonth;
        while (!workingDays.contains(candidate.getDayOfWeek())) {
            candidate = candidate.minusDays(1);
        }

        return localDate.isEqual(candidate);
    }

View on GitHub (pinned to 823fada927)

Solutions

  1. Provide an ISO 8601 date ('YYYY-MM-DD') or datetime ('YYYY-MM-DDTHH:mm:ss').
  2. Pre-format the date before passing.
  3. Inspect the appended parse error message.

Example fix

// before
{{ isLastWorkingDay(date='31/01/2024') }}
// after
{{ isLastWorkingDay(date='2024-01-31') }}
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Passing date like '31/01/2024' (locale order, slashes), 'Jan 31 2024', 'tomorrow', or an empty string.

Common situations: Locale-specific date formats, relative words, or a templated value that rendered to something unexpected.

Related errors


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