{"record":{"id":"5b51d20e7eaaad8b","repo":"Activiti/Activiti","slug":"l-option-is-not-valid-here-pos","errorCode":null,"errorMessage":"'L' option is not valid here. (pos=)","messagePattern":"'L' option is not valid here\\. \\(pos=\\)","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/calendar/CronExpression.java","lineNumber":567,"sourceCode":"    }\n\n    protected int checkNext(int pos, String s, int val, int type) throws ParseException {\n        int end = -1;\n        int i = pos;\n\n        if (i >= s.length()) {\n            addToSet(val, end, -1, type);\n            return i;\n        }\n\n        char c = s.charAt(pos);\n\n        if (c == 'L') {\n            if (type == DAY_OF_WEEK) {\n                if (val < 1 || val > 7) throw new ParseException(\"Day-of-Week values must be between 1 and 7\", -1);\n                lastdayOfWeek = true;\n            } else {\n                throw new ParseException(\"'L' option is not valid here. (pos=\" + i + \")\", i);\n            }\n            TreeSet<Integer> set = getSet(type);\n            set.add(Integer.valueOf(val));\n            i++;\n            return i;\n        }\n\n        if (c == 'W') {\n            if (type == DAY_OF_MONTH) {\n                nearestWeekday = true;\n            } else {\n                throw new ParseException(\"'W' option is not valid here. (pos=\" + i + \")\", i);\n            }\n            if (val > 31) throw new ParseException(\n                \"The 'W' option does not make sense with values larger than 31 (max number of days in a month)\",\n                i\n            );\n            TreeSet<Integer> set = getSet(type);","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/calendar/CronExpression.java#L549-L585","documentation":"checkNext throws this ParseException when the 'L' special character is used in a cron field other than day-of-week. The 'L' option is only legal as a suffix on the day-of-week field (e.g. '5L' = last Friday of month) or alone in day-of-month ('L' = last day); elsewhere it is a syntax error. Note the exception message uses the outer variable i (often 0 here) rather than the actual position, so the reported pos can be misleading.","triggerScenarios":"A cron expression containing 'L' in a field where it is not allowed, e.g. '0 0 L * * *'? no wait, day-of-month 'L' is handled elsewhere; concrete trigger is 'L' following a value parsed by checkNext in a non-DAY_OF_WEEK field, e.g. hours field '9L' ('0 9L * * *') or minute field '5L', or 'L' suffix on a month value.","commonSituations":"Copy-pasting cron strings between dialects where L is accepted in day-of-month but written into the wrong field; typos like '5L' in minute fields; generated expressions appending L after a generic numeric field; misunderstanding Quartz's field-specific L semantics.","solutions":["Move the 'L' to a field where it is valid: use 'L' alone in day-of-month for 'last day of month', or '<n>L' in day-of-week for 'last <n> weekday of month'.","Remove the stray 'L' from the invalid field and keep the plain numeric value.","Validate with CronExpression.isValidExpression before storing the cron string in configuration."],"exampleFix":"// before\nString cron = \"0 9L * * * ?\"; // throws: 'L' option is not valid here\n// after\nString cron = \"0 0 9 L * ?\"; // 09:00 on the last day of the month","handlingStrategy":"try-catch","validationCode":"if (!org.activiti.engine.impl.calendar.CronExpression.isValidExpression(cronString)) {\n    throw new IllegalArgumentException(\"Invalid cron expression: \" + cronString);\n}","typeGuard":null,"tryCatchPattern":"try {\n    new CronExpression(cronString);\n} catch (java.text.ParseException e) {\n    if (e.getMessage().contains(\"'L' option is not valid\")) {\n        // 'L' is only valid in day-of-month (alone) or day-of-week (as '<n>L');\n        // report the offending field to the user\n    }\n}","preventionTips":["Use 'L' only as: day-of-month 'L' (last day) or day-of-week '<n>L' (last nth weekday).","Validate cron strings with CronExpression.isValidExpression at config-load time, not first fire time.","When translating cron between dialects, translate special characters per target-field rules."],"tags":["cron","parse-error","activiti","syntax"],"backgroundTag":"invalid-argument-format","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}