Skip to content

[scheduler] parseRRule does not validate the FREQ value (string + object branches) #22769

Description

@rita-codes

Summary

parseRRule doesn't validate the FREQ value against the supported set. In the RRULE-string branch it only checks that FREQ is present, then casts it straight to the union — so an unsupported value like FREQ=HOURLY passes parsing and blows up later elsewhere with a message disconnected from the actual input. The object-input branch validates nothing at all.

Details

x-scheduler-internals-premium/src/internals/utils/recurring-events/rRuleString.ts:

String branch — checks presence but not the value:

if (!rruleObject.FREQ) { throw /* must include FREQ */ }
const rrule = { freq: rruleObject.FREQ as SchedulerProcessedEventRecurrenceRule['freq'] }; // unvalidated cast

It validates INTERVAL, BYDAY, etc., but not that FREQ is one of DAILY | WEEKLY | MONTHLY | YEARLY.

Object branch — no validation:

if (typeof input === 'object') {
  // only resolves `until`, returns the object as-is
}

Note on scope

The object branch is the typed API (SchedulerEventRecurrenceRule.freq is the union), so TS users are protected at compile time there — the real gap is the RRULE-string branch (a free-form string bypasses the types, so FREQ=HOURLY sneaks in). Validating both at runtime is the defensive choice (JS users / dynamic data can bypass either).

Suggested fix

Validate freq against the supported set (DAILY/WEEKLY/MONTHLY/YEARLY) at parse time in both branches, throwing a clear MUI X Scheduler: error (what happened / why / how to fix) that names the offending value — instead of a late, disconnected failure. Run pnpm extract-error-codes after adding the error.

Context

@mui/x-scheduler-internals-premium (master, pre-stable). Input validation / avoids a confusing late error; requires invalid input → Medium.

Metadata

Metadata

Assignees

Labels

scope: schedulerChanges related to the scheduler.type: enhancementIt’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions