kestra-io/kestra · error · PebbleException
The 'isWeekend()' function could not parse 'date': {e.getMes
Error message
The 'isWeekend()' function could not parse 'date': {e.getMessage()} What it means
The isWeekend(date) function delegates date parsing to DateUtils.parseLocalDate, which tries LocalDate.parse, then ZonedDateTime.parse, then LocalDateTime.parse. If all three fail, the InternalException is wrapped in this PebbleException with the underlying cause message appended. Only ISO 8601 date or datetime strings are accepted.
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/IsWeekendFunction.java:39
*
* @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");
}
@Override
// HashMap is required here because Map.of() does not allow null values,
// and null defaults indicate arguments with no meaningful autocompletion default.
public Map<String, String> getArgumentDefaults() {
HashMap<String, String> defaults = new HashMap<>();
defaults.put("date", null);
return defaults;View on GitHub (pinned to 823fada927)
Solutions
- Normalize the date to ISO 8601 yyyy-MM-dd or yyyy-MM-ddTHH:mm:ss before passing it.
- Check the appended e.getMessage() for the specific parse failure reason.
- If the source date uses a custom format, add an intermediate expression or task to convert it.
Example fix
# before
value: "{{ isWeekend('2024/01/15') }}"
# after
value: "{{ isWeekend('2024-01-15') }}" Defensive patterns
Strategy: validation
Validate before calling
# Validate ISO 8601 format before calling isWeekend:
{% set datePattern = /^\d{4}-\d{2}-\d{2}(T.*)?$/ %}
{% if myDateVar matches datePattern %}
{{ isWeekend(myDateVar) }}
{% else %}
{{ throw('date must be ISO 8601') }}
{% endif %} Prevention
- Normalize all date inputs to ISO 8601 in upstream tasks.
- Avoid passing locale-specific date formats directly to Pebble functions.
- Check the e.getMessage() in the error to identify the exact format mismatch.
When it happens
Trigger: Passing a non-ISO date string (e.g. '2024/01/15', '15-Jan-2024'); passing a timestamp in epoch millis; passing a locale-specific formatted string from an API response.
Common situations: An upstream HTTP task returns dates in MM/DD/YYYY or DD.MM.YYYY format. The user passes a datetime string with a non-standard separator or timezone abbreviation like 'EST' instead of an ISO offset.
Related errors
- The 'isPublicHoliday()' function could not parse 'date': {e.
- The 'isWeekend()' function expects a 'date' argument.
- The 'monthOfYear()' function could not parse 'date': %s
- {e.getMessage()}
- The key '{key}' does not exist in the namespace '{namespace}
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/658fad2d030ed40f.
Report an issue: GitHub.