{"record":{"id":"cf2ac9e8424ff624","repo":"kestra-io/kestra","slug":"the-dayofmonth-function-expects-a-date-argum","errorCode":null,"errorMessage":"The 'dayOfMonth()' function expects a 'date' argument.","messagePattern":"The 'dayOfMonth\\(\\)' function expects a 'date' argument\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfMonthFunction.java","lineNumber":31,"sourceCode":"import io.pebbletemplates.pebble.template.PebbleTemplate;\n\n/**\n * Pebble function that returns the day of the month (1–31) of the given date.\n *\n * <p>\n * Usage: {@code {{ dayOfMonth(date) }}}\n *\n * @param date any valid ISO 8601 date or datetime string\n */\npublic class DayOfMonthFunction implements KestraFunction {\n    public static final String NAME = \"dayOfMonth\";\n\n    @Override\n    public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {\n        Object dateArg = args.get(\"date\");\n\n        if (dateArg == null) {\n            throw new PebbleException(null, \"The 'dayOfMonth()' function expects a 'date' argument.\", lineNumber, self.getName());\n        }\n\n        LocalDate localDate;\n        try {\n            localDate = DateUtils.parseLocalDate(dateArg.toString());\n        } catch (InternalException e) {\n            throw new PebbleException(e, \"The 'dayOfMonth()' function could not parse 'date': \" + e.getMessage(), lineNumber, self.getName());\n        }\n\n        return localDate.getDayOfMonth();\n    }\n\n    @Override\n    public List<String> getArgumentNames() {\n        return List.of(\"date\");\n    }\n\n    @Override","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfMonthFunction.java#L13-L49","documentation":"The dayOfMonth() Pebble function returns the day of the month (1-31) of an ISO 8601 date/datetime string. It throws when the 'date' argument is absent/null (args.get(\"date\") == null). This is a missing-argument error, not a parse error.","triggerScenarios":"Calling {{ dayOfMonth() }} with no argument, or {{ dayOfMonth(missing) }} where 'missing' is undefined/null.","commonSituations":"Forgetting to pass a date; binding date to an optional output that is null for this run; typo in the argument name.","solutions":["Pass a valid date argument: {{ dayOfMonth(trigger.date) }} or {{ dayOfMonth('2024-01-15') }}.","Provide a fallback date: {{ dayOfMonth(myDate ?? execution.startDate) }}.","Ensure the variable feeding date is set by the upstream task."],"exampleFix":"// before\n{{ dayOfMonth() }}\n// after\n{{ dayOfMonth(date=execution.startDate) }}","handlingStrategy":"validation","validationCode":"{{ dayOfMonth(date=(myDate ?? execution.startDate)) }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a non-null date argument.","Provide a fallback date when the primary source is optional.","Use the expression editor to confirm the variable resolves."],"tags":["pebble","function","date","argument"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}