{"record":{"id":"7cb0277c4029b927","repo":"phacility/phabricator","slug":"value-s-in-rrule-s-parameter-is-invalid-it","errorCode":null,"errorMessage":"Value \"%s\" in RRULE \"%s\" parameter is invalid: it must be between %s and %s.","messagePattern":"Value \"(.+?)\" in RRULE \"(.+?)\" parameter is invalid: it must be between (.+?) and (.+?)\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/calendar/parser/data/PhutilCalendarRecurrenceRule.php","lineNumber":1596,"sourceCode":"  private function assertByRange(\n    $source,\n    array $values,\n    $min,\n    $max,\n    $allow_zero = true) {\n\n    foreach ($values as $value) {\n      if (!is_int($value)) {\n        throw new Exception(\n          pht(\n            'Value \"%s\" in RRULE \"%s\" parameter is invalid: values must be '.\n            'integers.',\n            $value,\n            $source));\n      }\n\n      if ($value < $min || $value > $max) {\n        throw new Exception(\n          pht(\n            'Value \"%s\" in RRULE \"%s\" parameter is invalid: it must be '.\n            'between %s and %s.',\n            $value,\n            $source,\n            $min,\n            $max));\n      }\n\n      if (!$value && !$allow_zero) {\n        throw new Exception(\n          pht(\n            'Value \"%s\" in RRULE \"%s\" parameter is invalid: it must not '.\n            'be zero.',\n            $value,\n            $source));\n      }\n    }","sourceCodeStart":1578,"sourceCodeEnd":1614,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/calendar/parser/data/PhutilCalendarRecurrenceRule.php#L1578-L1614","documentation":"assertByRange() bounds every value in an RRULE parameter list to a legal range (e.g. BYMONTH 1-12, BYWEEKNO -53..53, BYHOUR 0-23). Any value below the minimum or above the maximum for that parameter is rejected immediately, mirroring the numeric limits RFC5545 defines for each rule part.","triggerScenarios":"setByMonthDay(array(0, 32)) or an RRULE 'FREQ=MONTHLY;BYMONTHDAY=32'; setByMonth(array(13)); setByHour(array(24)); setByWeekNumber(array(54)); setBySetPosition(array(400)).","commonSituations":"Off-by-one mistakes when converting human input ('every month 1-13' style quarter notation); rules imported from producers with lax validation; unit tests probing boundary values.","solutions":["Clamp or correct the offending values to the RFC range for that parameter (BYMONTH 1-12, BYMONTHDAY -31..31, BYHOUR 0-23, etc.)","Validate user-supplied ranges before they reach the rule object","Re-check the RRULE string for typos like BYMONTH=13 or BYMONTHDAY=32"],"exampleFix":"// before\n$rrule = 'FREQ=MONTHLY;BYMONTHDAY=32';\n\n// after\n$rrule = 'FREQ=MONTHLY;BYMONTHDAY=31';","handlingStrategy":"validation","validationCode":"$ranges = array(\n  'BYMONTH' => array(1, 12),\n  'BYMONTHDAY' => array(-31, 31),\n  'BYYEARDAY' => array(-366, 366),\n  'BYWEEKNO' => array(-53, 53),\n  'BYHOUR' => array(0, 23),\n  'BYMINUTE' => array(0, 59),\n  'BYSECOND' => array(0, 60),\n);\nforeach ($ranges as $key => $bounds) {\n  if (isset($parts[$key])) {\n    foreach (explode(',', $parts[$key]) as $value) {\n      $value = (int)$value;\n      if ($value < $bounds[0] || $value > $bounds[1]) {\n        throw new Exception($key.' value out of range: '.$value);\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  $rule = PhutilCalendarRecurrenceRule::newFromRRule($rrule);\n} catch (Exception $ex) {\n  // Report which parameter and value failed by echoing $ex->getMessage().\n}","preventionTips":["Constrain form inputs (dropdowns/min-max) so out-of-range values cannot be submitted","Validate each BY* list against its RFC5545 range before building the rule","Log the offending RRULE verbatim when validation fails to speed diagnosis"],"tags":["rrule","icalendar","rfc5545","range-validation","calendar"],"backgroundTag":"rrule-validation-failed","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}