{"record":{"id":"a0a9747e399d0b47","repo":"instructure/canvas-lms","slug":"section-does-not-exist","errorCode":null,"errorMessage":"Section does not exist","messagePattern":"Section does not exist","errorType":"validation","errorClass":"PeerReview::SectionNotFoundError","httpStatus":null,"severity":"error","filePath":"app/services/peer_review/validations.rb","lineNumber":207,"sourceCode":"      raise PeerReview::InvalidDatesError,\n            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\")\n    end\n  end\n\n  def validate_set_type_required(set_type)\n    raise PeerReview::SetTypeRequiredError, I18n.t(\"Set type is required\") unless set_type.present?\n  end\n\n  def validate_set_id_required(set_id)\n    raise PeerReview::SetIdRequiredError, I18n.t(\"Set id is required\") unless set_id.present?\n  end\n\n  def validate_override_exists(override)\n    raise PeerReview::OverrideNotFoundError, I18n.t(\"Override does not exist\") unless override.present?\n  end\n\n  def validate_section_exists(section)\n    raise PeerReview::SectionNotFoundError, I18n.t(\"Section does not exist\") unless section.present?\n  end\n\n  def validate_course_exists(course)\n    raise PeerReview::CourseNotFoundError, I18n.t(\"Course does not exist\") unless course.present?\n  end\n\n  def validate_student_ids_required(student_ids)\n    if student_ids.nil? || student_ids == \"\" || student_ids.to_s.strip.empty? || (student_ids.is_a?(Array) && student_ids.empty?)\n      raise PeerReview::StudentIdsRequiredError, I18n.t(\"Student ids are required\")\n    end\n  end\n\n  def validate_student_ids_in_course(student_ids)\n    raise PeerReview::StudentIdsNotInCourseError, I18n.t(\"Student ids are not in course\") if student_ids.blank?\n  end\n\n  def validate_set_type_supported(set_type, services)\n    unless services.key?(set_type)","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/services/peer_review/validations.rb#L189-L225","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nsection = CourseSection.find_by(id: params[:section_id]) # possibly from another course\nservice.call(section: section)\n// after\nsection = course.course_sections.find(params[:section_id])\nservice.call(section: section)","handlingStrategy":"try-catch","validationCode":"section = course.course_sections.find_by(id: section_id)\nraise ArgumentError, 'section not found' unless section","typeGuard":null,"tryCatchPattern":"begin\n  service.call(section:)\nrescue PeerReview::SectionNotFoundError\n  head :not_found\nend","preventionTips":["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"],"tags":["ruby","peer-review","not-found","sections","canvas"],"backgroundTag":"record-not-found","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"}