{"record":{"id":"7062f89f0822864a","repo":"instructure/canvas-lms","slug":"peer-reviews-cannot-be-used-with-discussion-topic","errorCode":null,"errorMessage":"Peer reviews cannot be used with Discussion Topic assignments","messagePattern":"Peer reviews cannot be used with Discussion Topic assignments","errorType":"validation","errorClass":"PeerReview::InvalidAssignmentSubmissionTypesError","httpStatus":null,"severity":"error","filePath":"app/services/peer_review/validations.rb","lineNumber":49,"sourceCode":"  end\n\n  def validate_feature_enabled(assignment)\n    unless assignment.context.feature_enabled?(:peer_review_allocation_and_grading)\n      raise PeerReview::FeatureDisabledError, I18n.t(\"Peer Review Allocation and Grading feature flag is disabled\")\n    end\n  end\n\n  def validate_grading_type(grading_type)\n    raise PeerReview::InvalidGradingTypeError, I18n.t(\"Peer review sub assignments cannot have a not_graded grading type\") if grading_type == \"not_graded\"\n  end\n\n  def validate_assignment_submission_types(assignment)\n    if assignment.external_tool?\n      raise PeerReview::InvalidAssignmentSubmissionTypesError, I18n.t(\"Peer reviews cannot be used with External Tool assignments\")\n    end\n\n    if assignment.submission_types == \"discussion_topic\"\n      raise PeerReview::InvalidAssignmentSubmissionTypesError, I18n.t(\"Peer reviews cannot be used with Discussion Topic assignments\")\n    end\n  end\n\n  def validate_peer_review_sub_assignment_exists(assignment)\n    if assignment.peer_review_sub_assignment.blank?\n      raise PeerReview::SubAssignmentNotExistError, I18n.t(\"Peer review sub assignment does not exist\")\n    end\n  end\n\n  def validate_peer_review_sub_assignment_not_exist(assignment)\n    if assignment.peer_review_sub_assignment.present?\n      raise PeerReview::SubAssignmentExistsError, I18n.t(\"Peer review sub assignment exists\")\n    end\n  end\n\n  # Validates that peer review dates follow the restriction below\n  # peer review unlock_at < peer review due_at <= peer review lock_at\n  def validate_peer_review_dates(peer_review_dates)","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/services/peer_review/validations.rb#L31-L67","documentation":"The same validate_assignment_submission_types method raises PeerReview::InvalidAssignmentSubmissionTypesError when `assignment.submission_types == \"discussion_topic\"`. Discussion topic assignments are excluded from peer review sub assignments, so the library rejects them.","triggerScenarios":"Enabling peer reviews / creating a peer review sub assignment on an assignment whose submission_types is exactly 'discussion_topic'.","commonSituations":"Graded discussions with peer reviews requested by instructors; automation enabling peer review for every assignment type in a course; API clients copying settings from discussion assignments.","solutions":["Use a standard online-submission assignment instead of a graded discussion for peer reviews.","Check `assignment.submission_types == \"discussion_topic\"` and skip peer review creation for those.","Note that legacy discussion_topic peer review behavior differs from the new sub assignment flow; keep using the legacy path for discussions."],"exampleFix":"// before\nPeerReview::SubAssignmentCreator.new(assignment: discussion_assignment).call\n// after\nunless discussion_assignment.submission_types == \"discussion_topic\"\n  PeerReview::SubAssignmentCreator.new(assignment: discussion_assignment).call\nend","handlingStrategy":"validation","validationCode":"raise ArgumentError, \"discussion topics cannot use peer review sub assignments\" if assignment.submission_types == \"discussion_topic\"","typeGuard":null,"tryCatchPattern":"begin\n  service.call\nrescue PeerReview::InvalidAssignmentSubmissionTypesError => e\n  render json: { error: e.message }, status: :unprocessable_entity\nend","preventionTips":["Exclude discussion_topic submission_types in bulk peer review scripts","Keep graded discussions on the legacy peer review path","Check submission_types before showing the peer review toggle"],"tags":["peer-review","rails","validation","discussion-topic"],"backgroundTag":"unsupported-operation","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"}