{"record":{"id":"04add3117d8be8b0","repo":"instructure/canvas-lms","slug":"student-ids-are-required","errorCode":null,"errorMessage":"Student ids are required","messagePattern":"Student ids are required","errorType":"validation","errorClass":"PeerReview::StudentIdsRequiredError","httpStatus":null,"severity":"error","filePath":"app/services/peer_review/validations.rb","lineNumber":216,"sourceCode":"  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)\n      supported_types = services.keys.join(\", \")\n      raise PeerReview::SetTypeNotSupportedError,\n            I18n.t(\"Set type '%{set_type}' is not supported. Supported types are: %{supported_types}\", set_type:, supported_types:)\n    end\n  end\n\n  def validate_group_assignment_required(assignment)\n    unless assignment.group_category_id\n      raise PeerReview::GroupAssignmentRequiredError, I18n.t(\"Must be a group assignment to create group overrides\")","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/services/peer_review/validations.rb#L198-L234","documentation":"PeerReview::StudentIdsRequiredError raised by validate_student_ids_required when student_ids is nil, an empty string, a whitespace-only string, or an empty array. At least one target student is needed to create peer reviews.","triggerScenarios":"Calling a peer review creation service with student_ids: nil, '', '   ', or []; passing params[:student_ids] when the request body omitted the field.","commonSituations":"Frontend submits with no students selected; array filtered down to empty before the call; JSON payload uses wrong key so student_ids stays nil.","solutions":["Pass a non-empty array of student ids (e.g. [101, 102])","Fix the client to require at least one selected student before submit","Verify the param key name matches what the service expects"],"exampleFix":"// before\nservice.call(student_ids: params[:students] || []) # empty array\n// after\nreturn unless params[:students].present?\nservice.call(student_ids: params[:students].map(&:to_i))","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'student_ids must be a non-empty array' if student_ids.nil? || (student_ids.respond_to?(:empty?) && student_ids.empty?) || student_ids.to_s.strip.empty?","typeGuard":null,"tryCatchPattern":"begin\n  service.call(student_ids:)\nrescue PeerReview::StudentIdsRequiredError => e\n  render json: { error: e.message }, status: :bad_request\nend","preventionTips":["Enforce at-least-one-student selection in the UI before submit","Convert whitespace strings to arrays/ints early and re-check for emptiness","Use consistent param naming (student_ids) across client and service"],"tags":["ruby","peer-review","missing-parameter","empty-array","canvas"],"backgroundTag":"empty-required-field","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"}