phacility/phabricator · error · Exception

RRULE specifies BYYEARDAY with FREQ of DAILY, WEEKLY or MONT

Error message

RRULE specifies BYYEARDAY with FREQ of DAILY, WEEKLY or MONTHLY, which violates RFC5545.

What it means

RFC5545 forbids BYYEARDAY when FREQ is DAILY, WEEKLY, or MONTHLY, since a year-day index cannot be applied on those cycles. PhutilCalendarRecurrenceRule::resetSource() throws during rule initialization whenever both a BYYEARDAY list and one of those frequencies are present.

Source

Thrown at src/applications/calendar/parser/data/PhutilCalendarRecurrenceRule.php:592

          throw new Exception(
            pht(
              'RRULE specifies BYMONTHDAY with FREQ set to WEEKLY, which '.
              'violates RFC5545.'));
          break;
        default:
          break;
      }

    }

    if ($this->getByYearDay()) {
      switch ($frequency) {
        case self::FREQUENCY_DAILY:
        case self::FREQUENCY_WEEKLY:
        case self::FREQUENCY_MONTHLY:
          // RFC5545: "The BYYEARDAY rule part MUST NOT be specified when the
          // FREQ rule part is set to DAILY, WEEKLY, or MONTHLY."
          throw new Exception(
            pht(
              'RRULE specifies BYYEARDAY with FREQ of DAILY, WEEKLY or '.
              'MONTHLY, which violates RFC5545.'));
        default:
          break;
      }
    }

    // TODO
    // RFC5545: "The BYDAY rule part MUST NOT be specified with a numeric
    // value when the FREQ rule part is not set to MONTHLY or YEARLY."
    // RFC5545: "Furthermore, the BYDAY rule part MUST NOT be specified with a
    // numeric value with the FREQ rule part set to YEARLY when the BYWEEKNO
    // rule part is specified."


    $date = $this->getStartDateTime();

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Change FREQ to YEARLY (the only frequency where BYYEARDAY is meaningful)
  2. Remove the BYYEARDAY part and express the intent with BYMONTH/BYMONTHDAY instead
  3. Pre-screen imported RRULEs for the forbidden BYYEARDAY + DAILY/WEEKLY/MONTHLY combinations

Example fix

// before
$rrule = 'FREQ=MONTHLY;BYYEARDAY=100';

// after
$rrule = 'FREQ=YEARLY;BYYEARDAY=100';
Defensive patterns

Strategy: validation

Validate before calling

$forbidden = array('DAILY', 'WEEKLY', 'MONTHLY');
if (isset($parts['BYYEARDAY']) && in_array(idx($parts, 'FREQ'), $forbidden, true)) {
  throw new Exception('BYYEARDAY is not allowed with FREQ=DAILY/WEEKLY/MONTHLY.');
}

Try / catch

try {
  $rule = PhutilCalendarRecurrenceRule::newFromRRule($rrule);
  $rule->getEvents();
} catch (Exception $ex) {
  // Map to an import validation error for the offending .ics line.
}

Prevention

When it happens

Trigger: An RRULE such as 'FREQ=MONTHLY;BYYEARDAY=100', 'FREQ=DAILY;BYYEARDAY=1,366', or code calling setByYearDay(...) on a rule whose frequency is DAILY/WEEKLY/MONTHLY, followed by evaluation.

Common situations: Copy-pasted RRULE templates where FREQ was changed but BYYEARDAY kept; .ics producers that emit BYYEARDAY unconditionally; imports of rules authored against non-RFC tools.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/dccf3d6b03f37419. Report an issue: GitHub.