{"record":{"id":"687ff9f07702f60b","repo":"elsa-workflows/elsa-core","slug":"interval-expression-type-intervalexpression-type-is-not","errorCode":null,"errorMessage":"Interval expression type '{intervalExpression.Type}' is not supported.","messagePattern":"Interval expression type '(.+?)' is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Common/RecurringTasks/RecurringTaskScheduleManager.cs","lineNumber":28,"sourceCode":"    public ISchedule GetScheduleFor(Type taskType)\n    {\n        if (!ScheduledTasks.TryGetValue(taskType, out var schedule))\n        {\n            var intervalExpression = options.Value.Schedule.ScheduledTasks.TryGetValue(taskType, out var expr) ? expr : null;\n            schedule = intervalExpression != null ? CreateSchedule(intervalExpression) : new IntervalSchedule(TimeSpan.FromMinutes(1));\n            ScheduledTasks[taskType] = schedule;\n        }\n\n        return schedule;\n    }\n    \n    private ISchedule CreateSchedule(IntervalExpression intervalExpression)\n    {\n        return intervalExpression.Type switch\n        {\n            IntervalExpressionType.Cron => new CronSchedule(systemClock, CronExpression.Parse(intervalExpression.Expression)),\n            IntervalExpressionType.Interval => new IntervalSchedule(TimeSpan.Parse(intervalExpression.Expression)),\n            _ => throw new NotSupportedException($\"Interval expression type '{intervalExpression.Type}' is not supported.\")\n        };\n    }\n}","sourceCodeStart":10,"sourceCodeEnd":31,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Common/RecurringTasks/RecurringTaskScheduleManager.cs#L10-L31","documentation":"RecurringTaskScheduleManager.CreateSchedule maps an IntervalExpression to a CronSchedule or IntervalSchedule via a switch expression. An IntervalExpressionType outside the two known members falls to the discard arm and throws this NotSupportedException.","triggerScenarios":"Passing an IntervalExpression whose Type is neither Cron nor Interval — typically a new enum member added to IntervalExpressionType that this manager does not yet handle, or an uninitialized/default value.","commonSituations":"Upgrading Elsa adds a new interval type (e.g. custom schedule) while custom RecurringTask code or persisted expressions use it before the manager supports it; default(enum) leaking in.","solutions":["Only construct IntervalExpression with IntervalExpressionType.Cron or IntervalExpressionType.Interval.","Upgrade/patch so the schedule manager handles the newer interval expression type.","Validate the expression type before calling GetScheduleFor and reject unknown values early.","If you added an enum member, extend the switch in CreateSchedule with the matching schedule implementation."],"exampleFix":"// before\nnew IntervalExpression { Type = (IntervalExpressionType)99, Expression = \"...\" }\n// after\nnew IntervalExpression { Type = IntervalExpressionType.Interval, Expression = \"00:05:00\" }","handlingStrategy":"validation","validationCode":"if (expr.Type is not (IntervalExpressionType.Cron or IntervalExpressionType.Interval))\n    throw new ArgumentException($\"Interval type {expr.Type} is not supported by this scheduler.\");","typeGuard":"bool IsSupportedInterval(IntervalExpression e) => e.Type is IntervalExpressionType.Cron or IntervalExpressionType.Interval;","tryCatchPattern":"try { schedule = manager.GetScheduleFor(intervalExpression); }\ncatch (NotSupportedException ex) { logger.LogError(ex, \"Unsupported interval type {Type}\", intervalExpression.Type); }","preventionTips":["Validate expression types when parsing user-provided recurrence config","Re-check supported types after Elsa upgrades that extend IntervalExpressionType","Constrain persistence inputs to the supported enum values"],"tags":["scheduling","enum","unsupported"],"backgroundTag":"unsupported-enum-value","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}