kestra-io/kestra · error · PebbleException
The 'dayOfMonth()' function could not parse 'date': {e.getMe
Error message
The 'dayOfMonth()' function could not parse 'date': {e.getMessage()} What it means
dayOfMonth() delegates parsing to DateUtils.parseLocalDate and wraps any InternalException as a PebbleException. The error means the 'date' argument was present but not parseable as an ISO 8601 date/datetime (e.g. '15/01/2024', 'Jan 15', or a non-date string).
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfMonthFunction.java:38
*
* @param date any valid ISO 8601 date or datetime string
*/
public class DayOfMonthFunction implements KestraFunction {
public static final String NAME = "dayOfMonth";
@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 'dayOfMonth()' function expects a 'date' argument.", lineNumber, self.getName());
}
LocalDate localDate;
try {
localDate = DateUtils.parseLocalDate(dateArg.toString());
} catch (InternalException e) {
throw new PebbleException(e, "The 'dayOfMonth()' function could not parse 'date': " + e.getMessage(), lineNumber, self.getName());
}
return localDate.getDayOfMonth();
}
@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
- Pass an ISO 8601 value: 'yyyy-MM-dd' or 'yyyy-MM-dd'T'HH:mm:ss'.
- Reformat the upstream date to ISO before calling dayOfMonth using a script/output transformation.
- Validate the format before use and fall back to a known good date.
Example fix
// before
{{ dayOfMonth('15/01/2024') }}
// after
{{ dayOfMonth('2024-01-15') }} Defensive patterns
Strategy: validation
Validate before calling
// Pebble: normalize to ISO before calling dayOfMonth
{{ dayOfMonth(date=myDate | date(format="yyyy-MM-dd")) }} // if a date filter is available; otherwise reformat upstream 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
- Pass ISO 8601 dates only (yyyy-MM-dd or full datetime).
- Reformat locale-specific dates upstream before calling dayOfMonth.
- Bind date to a known date output field, not free text.
When it happens
Trigger: Passing a locale-specific format like {{ dayOfMonth('15-01-2024') }}, a relative word like 'today', or a value that is a string but not a date (e.g. an id).
Common situations: Upstream system emitting non-ISO dates; user-entered dates in DD/MM/YYYY; binding date to the wrong output field.
Related errors
- The 'dayOfWeek()' function could not parse 'date': {e.getMes
- 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/12390d4d24c47e32.
Report an issue: GitHub.