instructure/canvas-lms · error · PeerReview::PeerReviewsNotEnabledError
Peer reviews are not enabled for this assignment
Error message
Peer reviews are not enabled for this assignment
What it means
PeerReview::Validations#validate_peer_reviews_enabled raises PeerReview::PeerReviewsNotEnabledError when the target assignment does not have `peer_reviews?` truthy. Peer review sub-assignments only make sense for assignments that have peer reviews turned on, so the library short-circuits when the parent assignment lacks the setting.
Solutions
- Set `peer_reviews: true` on the assignment (assignment.update!(peer_reviews: true)) before running peer review services.
- Enable 'Peer Reviews' in the assignment edit UI before creating sub assignments.
- Guard the service call with `assignment.peer_reviews?` and skip or return early when disabled.
Example fix
// before PeerReview::SubAssignmentCreator.new(assignment: assignment).call # peer_reviews not set // after assignment.update!(peer_reviews: true) PeerReview::SubAssignmentCreator.new(assignment: assignment).call
Defensive patterns
Strategy: validation
Validate before calling
return render json: { error: "peer reviews disabled" }, status: :unprocessable_entity unless assignment.peer_reviews? Try / catch
begin
service.call
rescue PeerReview::PeerReviewsNotEnabledError => e
render json: { error: e.message }, status: :unprocessable_entity
end Prevention
- Require peer_reviews: true in the request contract
- Hide peer review UI until the assignment flag is on
- Check the flag before enqueuing background jobs
When it happens
Trigger: Creating or manipulating a peer review sub assignment for an assignment whose `peer_reviews` attribute is false/unset; API calls to peer review endpoints without `peer_reviews: true` on the assignment.
Common situations: Assignment created through the API without the peer_reviews flag; admin disabled peer reviews after sub assignment creation; seeding scripts that forget `peer_reviews: true`.
Related errors
- Due date cannot be before available from date
- Invalid parent assignment
- Must be a group assignment to create group overrides
- Peer Review Allocation and Grading feature flag is disabled
- Peer review sub assignment does not exist
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/e985d9ea94b4c031.
Report an issue: GitHub.
Appendix: source
Thrown at app/services/peer_review/validations.rb:29
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
module PeerReview::Validations
def validate_parent_assignment(assignment)
unless assignment.present? && assignment.is_a?(Assignment) && assignment.persisted?
raise PeerReview::InvalidParentAssignmentError, I18n.t("Invalid parent assignment")
end
end
def validate_peer_reviews_enabled(assignment)
unless assignment.peer_reviews?
raise PeerReview::PeerReviewsNotEnabledError, I18n.t("Peer reviews are not enabled for this assignment")
end
end
def validate_feature_enabled(assignment)
unless assignment.context.feature_enabled?(:peer_review_allocation_and_grading)
raise PeerReview::FeatureDisabledError, I18n.t("Peer Review Allocation and Grading feature flag is disabled")
end
end
def validate_grading_type(grading_type)
raise PeerReview::InvalidGradingTypeError, I18n.t("Peer review sub assignments cannot have a not_graded grading type") if grading_type == "not_graded"
end
def validate_assignment_submission_types(assignment)
if assignment.external_tool?
raise PeerReview::InvalidAssignmentSubmissionTypesError, I18n.t("Peer reviews cannot be used with External Tool assignments")
end
View on GitHub (pinned to 1c9f0bb801)