instructure/canvas-lms · error · PeerReview::SetIdRequiredError

Set id is required

Error message

Set id is required

What it means

PeerReview::SetIdRequiredError raised by validate_set_id_required when the set_id argument is blank. set_id identifies the specific set (group set, section set, etc.) from which peer review members are drawn.

Solutions

  1. Pass the numeric id of an existing set (e.g. group_category_id) as set_id
  2. Ensure the frontend requires set selection when set_type is given
  3. Look up the correct set id for the course before calling the service

Example fix

// before
validate_set_id_required(nil) # => raises
PeerReview::Service.call(set_type: 'group', set_id: nil)
// after
PeerReview::Service.call(set_type: 'group', set_id: group_category.id)
Defensive patterns

Strategy: validation

Validate before calling

raise ArgumentError, 'set_id is required' if params[:set_id].blank?

Try / catch

begin
  service.call(set_type: st, set_id: sid)
rescue PeerReview::SetIdRequiredError => e
  render json: { error: e.message }, status: :bad_request
end

Prevention

When it happens

Trigger: Calling a peer review service with set_type present but set_id nil, '' or otherwise not present; sending a payload that omits the id of the chosen set.

Common situations: UI lets user pick a set type but never a set; set was deleted so the client sends no id; API integrations copy set_type but not set_id between requests.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/255e83c867907774. Report an issue: GitHub.

Appendix: source

Thrown at app/services/peer_review/validations.rb:199

    # Validate: child due_at <= parent lock_at
    if child_due_at && parent_lock_at && child_due_at > parent_lock_at
      raise PeerReview::InvalidDatesError,
            is_override ? I18n.t("Peer review override due date cannot be after parent override until date") : I18n.t("Peer review due date cannot be after assignment until date")
    end

    # Validate: child lock_at <= parent lock_at
    if child_lock_at && parent_lock_at && child_lock_at > parent_lock_at
      raise PeerReview::InvalidDatesError,
            is_override ? I18n.t("Peer review override until date cannot be after parent override until date") : I18n.t("Peer review until date cannot be after assignment until date")
    end
  end

  def validate_set_type_required(set_type)
    raise PeerReview::SetTypeRequiredError, I18n.t("Set type is required") unless set_type.present?
  end

  def validate_set_id_required(set_id)
    raise PeerReview::SetIdRequiredError, I18n.t("Set id is required") unless set_id.present?
  end

  def validate_override_exists(override)
    raise PeerReview::OverrideNotFoundError, I18n.t("Override does not exist") unless override.present?
  end

  def validate_section_exists(section)
    raise PeerReview::SectionNotFoundError, I18n.t("Section does not exist") unless section.present?
  end

  def validate_course_exists(course)
    raise PeerReview::CourseNotFoundError, I18n.t("Course does not exist") unless course.present?
  end

  def validate_student_ids_required(student_ids)
    if student_ids.nil? || student_ids == "" || student_ids.to_s.strip.empty? || (student_ids.is_a?(Array) && student_ids.empty?)
      raise PeerReview::StudentIdsRequiredError, I18n.t("Student ids are required")
    end

View on GitHub (pinned to 1c9f0bb801)