{"record":{"id":"bbda159a649e03e1","repo":"flowable/flowable-engine","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":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/calendar/CronExpression.java","lineNumber":742,"sourceCode":"\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) {\n                    throw new ParseException(\"Day-of-Week values must be between 1 and 7\", -1);\n                }\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(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) {\n                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            }","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/calendar/CronExpression.java#L724-L760","documentation":"checkNext throws this when the 'L' (last-day) option character appears after a value in a field that is not DAY_OF_WEEK. 'L' is only valid as 'nL' in day-of-week, or alone in day-of-month (handled elsewhere in storeExpressionVals).","triggerScenarios":"Expressions using 'L' in wrong fields, e.g. \"0 0 0L * * ?\" (L after hour values), \"0 0 L 1 * ?\" reached through checkNext, or 'L' appended to month/second/minute values.","commonSituations":"Misunderstanding Quartz 'L' semantics; copy-pasting expressions from documentation for other cron dialects; typos where 'L' was meant for the day-of-month field.","solutions":["Use 'L' alone only in the day-of-month field: \"0 0 0 L * ?\"","Use 'nL' only in the day-of-week field: \"0 0 0 ? * 6L\" (last Friday)","Remove the stray 'L' from fields that do not support it"],"exampleFix":"// before\nnew CronExpression(\"0 0 0L * * ?\");\n// after\nnew CronExpression(\"0 0 0 L * ?\"); // last day of month","handlingStrategy":"validation","validationCode":"boolean validLOption(String[] fields) {\n    // fields in Quartz order: sec min hour dom mon dow [year]\n    boolean domL = fields[3].equals(\"L\") || fields[3].equals(\"LW\") || fields[3].matches(\"\\\\d+W\");\n    boolean dowL = fields[5].matches(\"[1-7]L|[A-Z]{3}L\");\n    return fields[0].matches(\"[0-9*/,-]+\") && fields[1].matches(\"[0-9*/,-]+\")\n        && fields[2].matches(\"[0-9*/,-]+\") && (fields[3].matches(\"[0-9*?/,-]+\") || domL)\n        && fields[4].matches(\"[A-Z0-9*?/,-]+\") && (fields[5].matches(\"[0-9?*/,-]+|[A-Z?,/-]+\") || dowL);\n}","typeGuard":null,"tryCatchPattern":"try {\n    CronExpression cron = new CronExpression(expr);\n} catch (ParseException e) {\n    if (e.getMessage().startsWith(\"'L' option is not valid here\")) {\n        throw new ConfigurationException(\"'L' is only valid alone in day-of-month or as nL in day-of-week: \" + expr, e);\n    }\n    throw e;\n}","preventionTips":["Remember: L alone -> day-of-month; nL -> day-of-week; LW -> last weekday of month","Do not put L in sec/min/hour/month/year fields","Validate expressions in tests before deployment"],"tags":["cron","l-option","quartz","parse-error"],"backgroundTag":"invalid-argument-format","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}