{"record":{"id":"658fad2d030ed40f","repo":"kestra-io/kestra","slug":"the-isweekend-function-could-not-parse-date","errorCode":null,"errorMessage":"The 'isWeekend()' function could not parse 'date': {e.getMessage()}","messagePattern":"The 'isWeekend\\(\\)' function could not parse 'date': (.+?)","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/IsWeekendFunction.java","lineNumber":39,"sourceCode":" *\n * @param date any valid ISO 8601 date or datetime string\n */\npublic class IsWeekendFunction implements KestraFunction {\n    public static final String NAME = \"isWeekend\";\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 'isWeekend()' 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 'isWeekend()' function could not parse 'date': \" + e.getMessage(), lineNumber, self.getName());\n        }\n\n        DayOfWeek dayOfWeek = localDate.getDayOfWeek();\n        return dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY;\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;","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/IsWeekendFunction.java#L21-L57","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nvalue: \"{{ isWeekend('2024/01/15') }}\"\n# after\nvalue: \"{{ isWeekend('2024-01-15') }}\"","handlingStrategy":"validation","validationCode":"# Validate ISO 8601 format before calling isWeekend:\n{% set datePattern = /^\\d{4}-\\d{2}-\\d{2}(T.*)?$/ %}\n{% if myDateVar matches datePattern %}\n  {{ isWeekend(myDateVar) }}\n{% else %}\n  {{ throw('date must be ISO 8601') }}\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["pebble-function","date-parsing","isweekend"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}