{"record":{"id":"75c94c904614a531","repo":"instructure/canvas-lms","slug":"invalid-freq-freq","errorCode":null,"errorMessage":"Invalid FREQ '%{freq}'","messagePattern":"Invalid FREQ '%(.+?)'","errorType":"validation","errorClass":"RruleValidationError","httpStatus":null,"severity":"warning","filePath":"app/helpers/rrule_helper.rb","lineNumber":44,"sourceCode":"\n# rubocop:disable Style/IfInsideElse\nmodule RruleHelper\n  RECURRING_EVENT_LIMIT = 400\n\n  def rrule_to_natural_language(rrule)\n    rropts = rrule_parse(rrule)\n    rrule_validate_common_opts(rropts)\n    case rropts[\"FREQ\"]\n    when \"DAILY\"\n      parse_daily(rropts)\n    when \"WEEKLY\"\n      parse_weekly(rropts)\n    when \"MONTHLY\"\n      parse_monthly(rropts)\n    when \"YEARLY\"\n      parse_yearly(rropts)\n    else\n      raise RruleValidationError, I18n.t(\"Invalid FREQ '%{freq}'\", freq: rropts[\"FREQ\"])\n    end\n  rescue => e\n    logger.error \"RRULE to natural language failure: #{e}\"\n    nil\n  end\n\n  def rrule_parse(rrule)\n    Hash[*rrule.sub(/^RRULE:/, \"\").split(/[;=]/)]\n  end\n\n  def rrule_validate_common_opts(rropts)\n    raise RruleValidationError, I18n.t(\"Missing INTERVAL\") unless rropts.key?(\"INTERVAL\")\n    raise RruleValidationError, I18n.t(\"INTERVAL must be > 0\") unless rropts[\"INTERVAL\"].to_i > 0\n\n    # We do not support never ending series because each event in the series\n    # must get created in the db to support the paginated calendar_events api\n    raise RruleValidationError, I18n.t(\"Missing COUNT or UNTIL\") unless rropts.key?(\"COUNT\") || rropts.key?(\"UNTIL\")\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/helpers/rrule_helper.rb#L26-L62","documentation":"rrule_to_natural_language maps an RRULE's FREQ (DAILY/WEEKLY/MONTHLY/YEARLY). An unrecognized FREQ raises RruleValidationError \"Invalid FREQ '%{freq}'\"; the surrounding rescue logs it and returns nil, so calendar events silently lose their natural-language description.","triggerScenarios":"Rendering a calendar_event_json for an event whose rrule field has FREQ values like SECONDLY, MINUTELY, HOURLY, or a malformed/empty FREQ (e.g. from an imported .ics with sub-daily recurrence).","commonSituations":"Importing external ICS feeds using SECONDLY/HOURLY recurrences; hand-edited rrule strings; data migrations from other calendar systems.","solutions":["Reject or normalize sub-daily FREQ values at ICS import time.","Catch RruleValidationError upstream and render a generic 'repeats on a custom schedule' string instead of nil.","Fix the stored rrule to a supported FREQ (DAILY/WEEKLY/MONTHLY/YEARLY).","Add validation on CalendarEvent save to whitelist supported FREQ values."],"exampleFix":"// before\nfreq = rropts['FREQ'] # 'HOURLY'\n// after\nunless %w[DAILY WEEKLY MONTHLY YEARLY].include?(rropts['FREQ'])\n  rropts['FREQ'] = 'DAILY' # or reject the event at import\nend","handlingStrategy":"validation","validationCode":"return nil unless %w[DAILY WEEKLY MONTHLY YEARLY].include?(rropts['FREQ'])","typeGuard":null,"tryCatchPattern":"desc = begin\n  rrule_to_natural_language(rrule)\nrescue RruleValidationError\n  I18n.t('repeats on a custom schedule')\nend","preventionTips":["Whitelist supported FREQ values at ICS import","Reject sub-daily recurrences (SECONDLY/MINUTELY/HOURLY) explicitly","Remember rrule_to_natural_language rescues and returns nil — check the return value"],"tags":["rrule","calendar","recurrence"],"backgroundTag":"invalid-enum-value","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}