{"record":{"id":"524ead9e09d55e10","repo":"instructure/canvas-lms","slug":"format-must-be-one-of-acceptable-format-types-join","errorCode":null,"errorMessage":"format must be one of #{ACCEPTABLE_FORMAT_TYPES.join(\",\")}","messagePattern":"format must be one of #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"app/helpers/application_helper.rb","lineNumber":838,"sourceCode":"  end\n\n  # used for generating a\n  # prompt for use with date pickers\n  # so it doesn't need to be declared all over the place\n  def datepicker_screenreader_prompt(format_input = \"datetime\")\n    prompt_text = I18n.t(\"#helpers.accessible_date_prompt\", \"Format Like\")\n    format = accessible_date_format(format_input)\n    \"#{prompt_text} #{format}\"\n  end\n\n  ACCEPTABLE_FORMAT_TYPES = %w[date time datetime].freeze\n\n  # useful for presenting a consistent\n  # date format to screenreader users across the app\n  # when telling them how to fill in a datetime field\n  def accessible_date_format(format = \"datetime\")\n    unless ACCEPTABLE_FORMAT_TYPES.include?(format)\n      raise ArgumentError, \"format must be one of #{ACCEPTABLE_FORMAT_TYPES.join(\",\")}\"\n    end\n\n    case format\n    when \"date\"\n      I18n.t(\"#helpers.accessible_date_only_format\", \"YYYY-MM-DD\")\n    when \"time\"\n      I18n.t(\"#helpers.accessible_time_only_format\", \"hh:mm\")\n    else\n      I18n.t(\"#helpers.accessible_date_format\", \"YYYY-MM-DD hh:mm\")\n    end\n  end\n\n  # render a link with a tooltip containing a summary of due dates\n  def multiple_due_date_tooltip(assignment, user, opts = {})\n    user ||= @current_user\n    presenter = OverrideTooltipPresenter.new(assignment, user, opts)\n    render \"shared/vdd_tooltip\", presenter:\n  end","sourceCodeStart":820,"sourceCodeEnd":856,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/helpers/application_helper.rb#L820-L856","documentation":"accessible_date_format in ApplicationHelper translates a format name ('date', 'time', 'datetime') into a screenreader-friendly string via I18n. It guard-clauses with an ArgumentError because only ACCEPTABLE_FORMAT_TYPES are supported; anything else would silently produce a wrong or missing I18n key.","triggerScenarios":"Calling accessible_date_format with a string outside ACCEPTABLE_FORMAT_TYPES, e.g. accessible_date_format('full') or a typo like 'datettime', or a caller forwarding an arbitrary UI-supplied format value.","commonSituations":"Adding a new datepicker variant and passing a new format name without updating ACCEPTABLE_FORMAT_TYPES; forwarding a param straight through to the helper; refactoring that renamed the accepted symbols.","solutions":["Pass only one of the accepted values: 'date', 'time', or 'datetime' (default)","Check ACCEPTABLE_FORMAT_TYPES in app/helpers/application_helper.rb for the exact list before calling","If a new format is genuinely needed, add it to ACCEPTABLE_FORMAT_TYPES and a matching 'when' branch with an I18n key","Fix typos in the call site"],"exampleFix":"// before\naccessible_date_format('calendar')\n// after\naccessible_date_format('date')","handlingStrategy":"validation","validationCode":"raise ArgumentError, format unless ACCEPTABLE_FORMAT_TYPES.include?(format)","typeGuard":null,"tryCatchPattern":"begin\n  prompt = accessible_date_format(format)\nrescue ArgumentError\n  prompt = accessible_date_format('datetime')\nend","preventionTips":["Only pass 'date', 'time', or 'datetime'","Define call sites against a constant or enum, not free strings","Add new formats to ACCEPTABLE_FORMAT_TYPES in the same change"],"tags":["ruby","i18n","invalid-argument"],"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"}