instructure/canvas-lms · error · PeerReview::SetTypeRequiredError
Set type is required
Error message
Set type is required
What it means
PeerReview::SetTypeRequiredError raised by validate_set_type_required when the set_type argument is blank (nil or empty). set_type selects which peer review set service (e.g. group set / section set) will handle the request.
Solutions
- Pass a valid set_type (e.g. 'group' or the service key registered in the services hash) in the request
- Ensure the caller reads set_type from params before invoking the service
- Validate the payload client-side before submitting
Example fix
// before PeerReview::Service.call(course:, set_id: 42) # set_type missing // after PeerReview::Service.call(course:, set_type: 'group', set_id: 42)
Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, 'set_type is required' if params[:set_type].blank?
Try / catch
begin
service.call(set_type: params[:set_type], ...)
rescue PeerReview::SetTypeRequiredError => e
render json: { error: e.message }, status: :bad_request
end Prevention
- Always pass set_type together with set_id for set-based peer reviews
- Validate required fields at the controller before calling services
- Keep the frontend form field and the param key name in sync
When it happens
Trigger: Calling a PeerReview service that requires a set (e.g. create_peer_review with group/section based sets) without passing set_type, or passing set_type: '' / nil.
Common situations: Omitting set_type in an API payload; a frontend form field not wired up; refactors that renamed the parameter without updating callers.
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
- Set id is required
- Student ids are required
- Course does not exist
- Override does not exist
- Peer review due date cannot be after assignment until date
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/44038e8c932368b7.
Report an issue: GitHub.
Appendix: source
Thrown at app/services/peer_review/validations.rb:195
raise PeerReview::InvalidDatesError,
is_override ? I18n.t("Peer review override due date cannot be before parent override due date") : I18n.t("Peer review due date cannot be before assignment due date")
end
# 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
View on GitHub (pinned to 1c9f0bb801)