instructure/canvas-lms · error · PeerReview::SectionNotFoundError
Section does not exist
Error message
Section does not exist
What it means
PeerReview::SectionNotFoundError raised by validate_section_exists when the given CourseSection is nil/not present. The section-based peer review service requires an existing section to resolve students.
Solutions
- Fetch the section within the course scope and verify it exists before calling the service
- Confirm the section id belongs to the same course and shard
- Re-sync/re-list sections after SIS changes and use a current id
Example fix
// before section = CourseSection.find_by(id: params[:section_id]) # possibly from another course service.call(section: section) // after section = course.course_sections.find(params[:section_id]) service.call(section: section)
Defensive patterns
Strategy: try-catch
Validate before calling
section = course.course_sections.find_by(id: section_id) raise ArgumentError, 'section not found' unless section
Try / catch
begin service.call(section:) rescue PeerReview::SectionNotFoundError head :not_found end
Prevention
- Always load sections through the course association to enforce scoping
- Re-list sections after SIS syncs before acting on stored ids
- Validate section_id belongs to the course in controller strong params flow
When it happens
Trigger: Calling the section peer review service with a section id that resolves to nothing: deleted section, section from another course, or wrong id type causing lookup failure.
Common situations: Sections merged or deleted in SIS sync between fetch and call; hardcoded section id from a different course; using course_section_id where none exists for the account.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Course does not exist
- Override does not exist
- Parent assignment Section override not found for section
- Group does not exist
- Parent assignment ADHOC override not found for students
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/a0a9747e399d0b47.
Report an issue: GitHub.
Appendix: source
Thrown at app/services/peer_review/validations.rb:207
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
end
def validate_student_ids_in_course(student_ids)
raise PeerReview::StudentIdsNotInCourseError, I18n.t("Student ids are not in course") if student_ids.blank?
end
def validate_set_type_supported(set_type, services)
unless services.key?(set_type)View on GitHub (pinned to 1c9f0bb801)