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
- Provide an ISO 8601 date ('YYYY-MM-DD') or datetime ('YYYY-MM-DDTHH:mm:ss').
- Pre-format the date before passing.
- 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
- Pass dates in ISO 8601 form: 'YYYY-MM-DD' or 'YYYY-MM-DDTHH:mm:ss'.
- Pre-format locale-specific dates into ISO form before passing.
- Inspect the appended parse error message for the failing token.
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
- The 'isDayWeekInMonth()' function could not parse 'date': {e
- The 'dayOfMonth()' function could not parse 'date': {e.getMe
- The 'dayOfWeek()' function could not parse 'date': {e.getMes
- The 'hourOfDay()' function could not parse 'date': {e2.getMe
- %s can't be converted to long
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/fca1b1c815ecbfc2.
Report an issue: GitHub.