{"record":{"id":"6c6b11a1ab894a90","repo":"kestra-io/kestra","slug":"the-isdayweekinmonth-function-received-an-inva-6c6b11","errorCode":null,"errorMessage":"The 'isDayWeekInMonth()' function received an invalid 'position' value: '{positionArg}'. Expected one of: FIRST, SECOND, THIRD, FOURTH, LAST.","messagePattern":"The 'isDayWeekInMonth\\(\\)' function received an invalid 'position' value: '(.+?)'\\. Expected one of: FIRST, SECOND, THIRD, FOURTH, LAST\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/IsDayWeekInMonthFunction.java","lineNumber":74,"sourceCode":"        DayOfWeek dayOfWeek;\n        try {\n            dayOfWeek = DayOfWeek.valueOf(dayOfWeekArg.toString().toUpperCase());\n        } catch (IllegalArgumentException e) {\n            throw new PebbleException(\n                e,\n                \"The 'isDayWeekInMonth()' function received an invalid 'dayOfWeek' value: '\" + dayOfWeekArg\n                    + \"'. Expected one of: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY.\",\n                lineNumber, self.getName()\n            );\n        }\n\n        LocalDate computed = switch (positionArg.toString().toUpperCase()) {\n            case \"FIRST\" -> localDate.with(TemporalAdjusters.firstInMonth(dayOfWeek));\n            case \"SECOND\" -> localDate.with(TemporalAdjusters.firstInMonth(dayOfWeek)).plusWeeks(1);\n            case \"THIRD\" -> localDate.with(TemporalAdjusters.firstInMonth(dayOfWeek)).plusWeeks(2);\n            case \"FOURTH\" -> localDate.with(TemporalAdjusters.firstInMonth(dayOfWeek)).plusWeeks(3);\n            case \"LAST\" -> localDate.with(TemporalAdjusters.lastInMonth(dayOfWeek));\n            default -> throw new PebbleException(\n                null, \"The 'isDayWeekInMonth()' function received an invalid 'position' value: '\" + positionArg + \"'. Expected one of: FIRST, SECOND, THIRD, FOURTH, LAST.\", lineNumber,\n                self.getName()\n            );\n        };\n\n        return computed.isEqual(localDate);\n    }\n\n    @Override\n    public List<String> getArgumentNames() {\n        return List.of(\"date\", \"dayOfWeek\", \"position\");\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<>();","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/IsDayWeekInMonthFunction.java#L56-L92","documentation":"The position argument must be one of FIRST, SECOND, THIRD, FOURTH, LAST (case-insensitive). The switch statement fell through to its default branch.","triggerScenarios":"Passing position='1ST', '1', 'LASTDAY', 'THIRDLY', or a typo such as 'FORTH'.","commonSituations":"Using ordinals/numbers or misspellings instead of the exact keyword.","solutions":["Use exactly FIRST, SECOND, THIRD, FOURTH, or LAST (any case; it is upper-cased internally)."],"exampleFix":"// before\n{{ isDayWeekInMonth(date='2024-01-15', dayOfWeek='MONDAY', position='1ST') }}\n// after\n{{ isDayWeekInMonth(date='2024-01-15', dayOfWeek='MONDAY', position='FIRST') }}","handlingStrategy":"validation","validationCode":"{% set p = position|upper %}{% if p in ['FIRST','SECOND','THIRD','FOURTH','LAST'] %}{{ isDayWeekInMonth(date=myDate, dayOfWeek='MONDAY', position=p) }}{% endif %}","typeGuard":"{% macro is_valid_position(p) %}{{ p|upper in ['FIRST','SECOND','THIRD','FOURTH','LAST'] }}{% endmacro %}","tryCatchPattern":null,"preventionTips":["Use exactly FIRST, SECOND, THIRD, FOURTH, or LAST.","Do not use ordinals like '1ST' or numbers like '1'."],"tags":["pebble","date","enum","validation"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}