{"record":{"id":"93ce6be04a736f56","repo":"instructure/canvas-lms","slug":"group-does-not-exist","errorCode":null,"errorMessage":"Group does not exist","messagePattern":"Group does not exist","errorType":"validation","errorClass":"PeerReview::GroupNotFoundError","httpStatus":null,"severity":"error","filePath":"app/services/peer_review/validations.rb","lineNumber":239,"sourceCode":"    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\")\n    end\n  end\n\n  def validate_group_exists(group)\n    raise PeerReview::GroupNotFoundError, I18n.t(\"Group does not exist\") unless group.present?\n  end\n\n  def validate_adhoc_parent_override_exists(parent_override, student_ids)\n    unless parent_override.present?\n      raise PeerReview::ParentOverrideNotFoundError,\n            I18n.t(\"Parent assignment ADHOC override not found for students %{student_ids}\", student_ids: student_ids.join(\", \"))\n    end\n  end\n\n  def validate_course_parent_override_exists(parent_override, course_id)\n    unless parent_override.present?\n      raise PeerReview::ParentOverrideNotFoundError,\n            I18n.t(\"Parent assignment Course override not found for course %{course_id}\", course_id:)\n    end\n  end\n\n  def validate_group_parent_override_exists(parent_override, group_id)\n    unless parent_override.present?","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/services/peer_review/validations.rb#L221-L257","documentation":"PeerReview::GroupNotFoundError raised when validate_group_exists receives a nil/blank group. The service could not load the Group referenced for the override, so it refuses to proceed rather than creating an override bound to a nonexistent group.","triggerScenarios":"Calling a PeerReview group override service with a group_id that does not exist, was deleted, or belongs to a different course/shard — the resulting Group lookup returns nil.","commonSituations":"Stale group id cached in the client after the group was deleted; wrong course context; cross-shard id confusion in a Switchman-sharded Canvas; typo in the id.","solutions":["Check the group id exists in the target course: course.groups.exists?(group_id)","Re-fetch the group list for the assignment's group category — the group may have been deleted","Verify you are not mixing shard-local and global ids in a multi-shard environment","Pass the Group record itself when the service accepts it, so resolution happens in the right context"],"exampleFix":"// before\nPeerReview::CreateGroupOverride.call(assignment:, group_id: params[:group_id])\n// after\ngroup = assignment.group_category.groups.find_by(id: params[:group_id])\nraise ArgumentError, 'group not in assignment group set' unless group\nPeerReview::CreateGroupOverride.call(assignment:, group_id: group.id)","handlingStrategy":"validation","validationCode":"group = Group.active.find_by(id: group_id)\nraise ArgumentError, 'group not found' unless group&.context == course","typeGuard":"null","tryCatchPattern":"begin\n  PeerReview::CreateGroupOverride.call(assignment:, group_id:)\nrescue PeerReview::GroupNotFoundError\n  render json: { error: 'Group does not exist' }, status: :not_found\nend","preventionTips":["Refresh group ids from the API rather than caching stale ids","Validate the group belongs to the assignment's group_category before calling","Be careful with global vs local ids in sharded environments"],"tags":["ruby","rails","peer-review","groups","not-found"],"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"}