{"record":{"id":"c30d6fb35d97d546","repo":"kestra-io/kestra","slug":"the-dayofweek-function-could-not-parse-date","errorCode":null,"errorMessage":"The 'dayOfWeek()' function could not parse 'date': {e.getMessage()}","messagePattern":"The 'dayOfWeek\\(\\)' function could not parse 'date': (.+?)","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfWeekFunction.java","lineNumber":48,"sourceCode":" *\n * @param date any valid ISO 8601 date or datetime string\n */\npublic class DayOfWeekFunction implements KestraFunction {\n    public static final String NAME = \"dayOfWeek\";\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 'dayOfWeek()' 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 'dayOfWeek()' function could not parse 'date': \" + e.getMessage(), lineNumber, self.getName());\n        }\n\n        return localDate.getDayOfWeek().name();\n    }\n\n    @Override\n    public List<String> getArgumentNames() {\n        return List.of(\"date\");\n    }\n\n    @Override\n    // HashMap is required here because Map.of() does not allow null values,\n    // and null defaults indicate arguments with no meaningful autocompletion default.\n    public Map<String, String> getArgumentDefaults() {\n        HashMap<String, String> defaults = new HashMap<>();\n        defaults.put(\"date\", null);\n        return defaults;\n    }","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/DayOfWeekFunction.java#L30-L66","documentation":"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).","triggerScenarios":"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.","commonSituations":"Locale-specific date formats from external systems; binding the wrong (non-date) output field; assuming dayOfWeek accepts any human-readable date.","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."],"exampleFix":"// before\n{{ dayOfWeek('Jan 15, 2024') }}\n// after\n{{ dayOfWeek('2024-01-15') }}","handlingStrategy":"validation","validationCode":"// Pass an ISO 8601 value\n{{ dayOfWeek(date='2024-01-15') }}","typeGuard":"// Java: ISO 8601 date pattern check\nString iso = \"^\\\\d{4}-\\\\d{2}-\\\\d{2}(T\\\\d{2}:\\\\d{2}(:\\\\d{2})?(\\\\.\\\\d+)?(Z|[+-]\\\\d{2}:\\\\d{2})?)?$\";\nif (!dateArg.toString().matches(iso)) throw new IllegalArgumentException(\"date is not ISO 8601\");","tryCatchPattern":null,"preventionTips":["Use ISO 8601 input only.","Normalize non-ISO dates upstream before calling dayOfWeek.","Do not pass human-readable day names or locale formats."],"tags":["pebble","function","date","parse","iso8601"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}