kestra-io/kestra · error · PebbleException
The 'dayOfWeek()' function could not parse 'date': {e.getMes
Error message
The 'dayOfWeek()' function could not parse 'date': {e.getMessage()} What it means
dayOfWeek() parses the date via DateUtils.parseLocalDate and wraps InternalException in a PebbleException. The error means the 'date' argument was supplied but could not be parsed as ISO 8601 (e.g. '01-15-2024', 'Monday', or another non-date string).
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfWeekFunction.java:48
*
* @param date any valid ISO 8601 date or datetime string
*/
public class DayOfWeekFunction implements KestraFunction {
public static final String NAME = "dayOfWeek";
@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 'dayOfWeek()' function expects a 'date' argument.", lineNumber, self.getName());
}
LocalDate localDate;
try {
localDate = DateUtils.parseLocalDate(dateArg.toString());
} catch (InternalException e) {
throw new PebbleException(e, "The 'dayOfWeek()' function could not parse 'date': " + e.getMessage(), lineNumber, self.getName());
}
return localDate.getDayOfWeek().name();
}
@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
- Use ISO 8601 input: 'yyyy-MM-dd' or 'yyyy-MM-dd'T'HH:mm:ss'.
- Normalize the upstream date to ISO with a transformation before calling dayOfWeek.
- Validate the string matches an ISO date pattern before use.
Example fix
// before
{{ dayOfWeek('Jan 15, 2024') }}
// after
{{ dayOfWeek('2024-01-15') }} Defensive patterns
Strategy: validation
Validate before calling
// Pass an ISO 8601 value
{{ dayOfWeek(date='2024-01-15') }} Type guard
// Java: ISO 8601 date pattern check
String iso = "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2})?(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$";
if (!dateArg.toString().matches(iso)) throw new IllegalArgumentException("date is not ISO 8601"); Prevention
- Use ISO 8601 input only.
- Normalize non-ISO dates upstream before calling dayOfWeek.
- Do not pass human-readable day names or locale formats.
When it happens
Trigger: Passing a non-ISO or non-date string: {{ dayOfWeek('15/01/2024') }}, {{ dayOfWeek('Monday') }}, or an output field that is text rather than a date.
Common situations: Locale-specific date formats from external systems; binding the wrong (non-date) output field; assuming dayOfWeek accepts any human-readable date.
Related errors
- The 'dayOfMonth()' function could not parse 'date': {e.getMe
- The 'dayOfMonth()' function expects a 'date' argument.
- The 'dayOfWeek()' function expects a 'date' argument.
- The 'hourOfDay()' function could not parse 'date': {e2.getMe
- The 'isDayWeekInMonth()' function could not parse 'date': {e
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/c30d6fb35d97d546.
Report an issue: GitHub.