{"record":{"id":"a0c50af0aa2dd4ef","repo":"flowable/flowable-engine","slug":"illegal-characters-for-this-position","errorCode":null,"errorMessage":"Illegal characters for this position: '","messagePattern":"Illegal characters for this position: '","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":603,"sourceCode":"                        }\n                    } else if (c == '#') {\n                        try {\n                            i += 4;\n                            nthdayOfWeek = Integer.parseInt(s.substring(i));\n                            if (nthdayOfWeek < 1 || nthdayOfWeek > 5) {\n                                throw new Exception();\n                            }\n                        } catch (Exception e) {\n                            throw new ParseException(\"A numeric value between 1 and 5 must follow the '#' option\", i);\n                        }\n                    } else if (c == 'L') {\n                        lastdayOfWeek = true;\n                        i++;\n                    }\n                }\n\n            } else {\n                throw new ParseException(\"Illegal characters for this position: '\" + sub + \"'\", i);\n            }\n            if (eval != -1) {\n                incr = 1;\n            }\n            addToSet(sval, eval, incr, type);\n            return (i + 3);\n        }\n\n        if (c == '?') {\n            i++;\n            if ((i + 1) < s.length() && (s.charAt(i) != ' ' && s.charAt(i + 1) != '\\t')) {\n                throw new ParseException(\"Illegal character after '?': \" + s.charAt(i), i);\n            }\n            if (type != DAY_OF_WEEK && type != DAY_OF_MONTH) {\n                throw new ParseException(\"'?' can only be specified for Day-of-Month or Day-of-Week.\", i);\n            }\n            if (type == DAY_OF_WEEK && !lastdayOfMonth) {\n                int val = daysOfMonth.last();","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/calendar/CronExpression.java#L585-L621","documentation":"The final fallback in storeExpressionVals: the current field's first token does not match any known type handler (second-of-minute, minute, hour, day-of-month, month, day-of-week) keyword/value forms, so the parser rejects the token as illegal for that position. This typically means the cron string has the wrong number of fields or contains characters the field grammar does not allow.","triggerScenarios":"new CronExpression(\"0 0 12 * * *\tFOO\") or any expression where a field starts with characters that fit no pattern — e.g. 8 tokens where the 8th lands where no handler exists, or an alphabetic token in a purely numeric field like month 'JANU' typo, or using '@daily' shorthand macros which Quartz-style parsers do not support.","commonSituations":"Using Unix shorthand macros ('@hourly', '@reboot') not supported by Flowable/Quartz cron; wrong field count causing tokens to fall in unexpected positions; stray whitespace-split garbage from config files; environment-variable substitution leaving 'unset' or empty-derived junk in the expression.","solutions":["Expand shorthand macros manually: '@daily' -> '0 0 0 * * ?'.","Count the fields: Quartz-style cron needs 6 or 7 (sec min hour dom month dow [year]).","Check each field's legal characters; alphabetic names only for month (JAN-DEC) and day-of-week (SUN-SAT).","Log/inspect the actual expression string at parse time — a template or property substitution may be injecting bad text."],"exampleFix":"// before\nnew CronExpression(\"@daily\");\n// after\nnew CronExpression(\"0 0 0 * * ?\");","handlingStrategy":"validation","validationCode":"int fields = expr.trim().split(\"\\\\s+\").length;\nif (fields < 6 || fields > 7) {\n    throw new IllegalArgumentException(\"Cron must have 6-7 fields: \" + expr);\n}\nif (expr.startsWith(\"@\")) {\n    throw new IllegalArgumentException(\"Shorthand macros (@daily) not supported; expand manually\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    new CronExpression(expr);\n} catch (java.text.ParseException e) {\n    throw new IllegalArgumentException(\"Unparseable cron expression: \" + expr, e);\n}","preventionTips":["Never use Unix @macros; expand to 6-field form","Verify field count before parsing","Inspect raw config values — templating may inject garbage tokens"],"tags":["cron","parse-error","syntax"],"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-14T11:17:12.474Z"}