{"record":{"id":"ac9a649d5cedafa3","repo":"instructure/canvas-lms","slug":"invalid-date-type-date-type","errorCode":null,"errorMessage":"invalid date type: #{date[:type]}","messagePattern":"invalid date type: #(.+?)","errorType":"exception","errorClass":"Checkpoints::InvalidDateTypeError","httpStatus":null,"severity":"error","filePath":"app/services/checkpoints/discussion_checkpoint_common_service.rb","lineNumber":49,"sourceCode":"  end\n\n  private\n\n  def validate_flag_enabled\n    unless @discussion_topic.context.discussion_checkpoints_enabled?\n      raise Checkpoints::FlagDisabledError, \"discussion_checkpoints feature flag must be enabled\"\n    end\n  end\n\n  def validate_dates\n    valid_date_types = %w[everyone override].freeze\n\n    @dates.each do |date|\n      if date[:type].blank?\n        raise Checkpoints::DateTypeRequiredError, \"each date must have a type specified ('everyone' or 'override')\"\n      end\n      unless valid_date_types.include?(date[:type])\n        raise Checkpoints::InvalidDateTypeError, \"invalid date type: #{date[:type]}\"\n      end\n    end\n  end\n\n  def attributes_to_inherit_from_parent\n    # TODO: handle peer reviews\n    %w[\n      assignment_group_id\n      context_id\n      context_type\n      description\n      grade_group_students_individually\n      grading_type\n      grading_standard_id\n      group_category\n      group_category_id\n      position\n      submission_types","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/services/checkpoints/discussion_checkpoint_common_service.rb#L31-L67","documentation":"In validate_dates, after confirming a date's :type is present, it is checked against the whitelist %w[everyone override]; any other value raises InvalidDateTypeError with the offending value. This prevents silently ignoring misspelled types that would otherwise produce dates no service handles.","triggerScenarios":"Passing a date hash whose :type is non-blank but not 'everyone'/'override', e.g. type: 'section', 'student', 'Everyone', 'all', or 'overrides' (plural).","commonSituations":"Typos and casing mistakes in client payloads; developers extending the date model with new types without updating this whitelist; other Canvas date vocabularies (e.g. 'CourseSection' set_type) mistakenly used as the type value.","solutions":["Change the date's type to exactly 'everyone' or 'override' (lowercase).","Fix client-side dropdown/enum mappings that emit different strings.","If a new type is genuinely needed, update valid_date_types in discussion_checkpoint_common_service.rb along with handling code."],"exampleFix":"// before\ndates: [{ type: 'overrides', due_at: t }]\n// after\ndates: [{ type: 'override', due_at: t }]","handlingStrategy":"validation","validationCode":"VALID = %w[everyone override].freeze\ndates.each { |d| raise ArgumentError, \"bad type #{d[:type]}\" unless VALID.include?(d[:type]) }","typeGuard":"def valid_date_types?(dates)\n  dates.all? { |d| %w[everyone override].include?(d[:type].to_s) }\nend","tryCatchPattern":"begin\n  service.call(...)\nrescue Checkpoints::InvalidDateTypeError => e\n  render json: { error: e.message }, status: :bad_request\nend","preventionTips":["Use a shared enum constant for date types across client and server","Never use AssignmentOverride set_type strings as date types","Test payloads with both allowed values to catch typos early"],"tags":["ruby","canvas","validation","enum"],"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"}