Foundry376/Mailspring · error

Invalid ICS: expected VCALENDAR root

Error message

Invalid ICS: expected VCALENDAR root

What it means

Guard in applyEditsToException: the parsed ICS root component is not a VCALENDAR (or has no VCALENDAR wrapper), which this routine requires to search for exception VEVENTs. Usually means a bare-VEVENT payload was passed where a full calendar wrapper was expected.

Source

Thrown at app/src/ics-event-helpers.ts:672

 * @param edits - Property values to apply
 * @returns Updated master ICS string
 */
export function applyEditsToException(
  masterIcs: string,
  recurrenceId: string,
  edits: {
    summary?: string;
    location?: string;
    description?: string;
    attendees?: Array<{ email: string; name?: string | null; partstat?: string }>;
  }
): string {
  const ical = getICAL();
  const { root } = parseICSString(masterIcs);

  const vcalendar = root.name === 'vcalendar' ? root : null;
  if (!vcalendar) {
    throw new Error('Invalid ICS: expected VCALENDAR root');
  }

  // Find the exception VEVENT by RECURRENCE-ID
  let exceptionVevent: ICALComponent | null = null;
  for (const vevent of vcalendar.getAllSubcomponents('vevent')) {
    const rid = vevent.getFirstPropertyValue('recurrence-id');
    if (rid) {
      const ridStr =
        typeof rid === 'string'
          ? rid
          : typeof (rid as any).toString === 'function'
            ? (rid as any).toString()
            : String(rid);
      if (
        ridStr === recurrenceId ||
        ridStr.replace(/[^0-9TZ]/g, '') === recurrenceId.replace(/[^0-9TZ]/g, '')
      ) {
        exceptionVevent = vevent;

View on GitHub (pinned to 648c685d60)

Solutions

  1. Pass the full VCALENDAR ICS (BEGIN:VCALENDAR ... END:VCALENDAR) rather than a bare VEVENT
  2. Wrap the parsed event in a VCALENDAR component before calling applyEditsToException
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at app/src/ics-event-helpers.ts:672 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Foundry376/Mailspring@648c685d60 (2026-09-03). Data as JSON: /api/errors/92e295c00ed71bf1. Report an issue: GitHub.