{"record":{"id":"f40c4f4397e17ed8","repo":"flowable/flowable-engine","slug":"unexpected-type-encountered","errorCode":null,"errorMessage":"Unexpected type encountered","messagePattern":"Unexpected type encountered","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/calendar/CronExpression.java","lineNumber":1074,"sourceCode":"            }\n        }\n\n        // if the end of the range is before the start, then we need to overflow\n        // into\n        // the next day, month etc. This is done by adding the maximum amount\n        // for that\n        // type, and using modulus max to determine the value being added.\n        int max = -1;\n        if (stopAt < startAt) {\n            max = switch (type) {\n                case SECOND -> 60;\n                case MINUTE -> 60;\n                case HOUR -> 24;\n                case MONTH -> 12;\n                case DAY_OF_WEEK -> 7;\n                case DAY_OF_MONTH -> 31;\n                case YEAR -> throw new IllegalArgumentException(\"Start year must be less than stop year\");\n                default -> throw new IllegalArgumentException(\"Unexpected type encountered\");\n            };\n            stopAt += max;\n        }\n\n        for (int i = startAt; i <= stopAt; i += incr) {\n            if (max == -1) {\n                // ie: there's no max to overflow over\n                set.add(i);\n            } else {\n                // take the modulus to get the real value\n                int i2 = i % max;\n\n                // 1-indexed ranges should not include 0, and should include\n                // their max\n                if (i2 == 0 && (type == MONTH || type == DAY_OF_WEEK || type == DAY_OF_MONTH)) {\n                    i2 = max;\n                }\n","sourceCodeStart":1056,"sourceCodeEnd":1092,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/calendar/CronExpression.java#L1056-L1092","documentation":"Defensive switch guard inside CronExpression: while computing a wrapped range (stopAt < startAt overflow handling) the calendar field type is not one of SECOND/MINUTE/HOUR/MONTH/DAY_OF_WEEK/DAY_OF_MONTH, i.e. an unhandled/unknown type token reached internal logic. It is a sentinel for an impossible-by-construction state, indicating corrupted parsing state or a code path passing an invalid type.","triggerScenarios":"Thrown at modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/calendar/CronExpression.java:1074 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Not reachable through normal cron parsing; if hit, capture the exact cron expression and file a bug against the calendar component","Verify any custom code that calls CronExpression internals with hand-built type constants"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}