{"record":{"id":"2d8b3bee28ce2a4d","repo":"instructure/canvas-lms","slug":"peer-review-allocation-and-grading-feature-flag-is-disabled","errorCode":null,"errorMessage":"Peer Review Allocation and Grading feature flag is disabled","messagePattern":"Peer Review Allocation and Grading feature flag is disabled","errorType":"validation","errorClass":"PeerReview::FeatureDisabledError","httpStatus":null,"severity":"error","filePath":"app/services/peer_review/validations.rb","lineNumber":35,"sourceCode":"# You should have received a copy of the GNU Affero General Public License along\n# with this program. If not, see <http://www.gnu.org/licenses/>.\n\nmodule PeerReview::Validations\n  def validate_parent_assignment(assignment)\n    unless assignment.present? && assignment.is_a?(Assignment) && assignment.persisted?\n      raise PeerReview::InvalidParentAssignmentError, I18n.t(\"Invalid parent assignment\")\n    end\n  end\n\n  def validate_peer_reviews_enabled(assignment)\n    unless assignment.peer_reviews?\n      raise PeerReview::PeerReviewsNotEnabledError, I18n.t(\"Peer reviews are not enabled for this assignment\")\n    end\n  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)","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/services/peer_review/validations.rb#L17-L53","documentation":"PeerReview::Validations#validate_feature_enabled raises PeerReview::FeatureDisabledError when the assignment's root account/context does not have the `:peer_review_allocation_and_grading` feature flag enabled. This new peer review allocation/grading functionality is gated behind a Canvas feature flag, so all peer review sub assignment operations fail until the flag is on.","triggerScenarios":"Any peer review sub assignment creation/update on an account where the `peer_review_allocation_and_grading` feature flag is 'off' or 'allowed' but not enabled in the assignment's context.","commonSituations":"Testing on a local/self-hosted Canvas where the flag was never turned on; production rollout where only some accounts have the flag enabled; staging environments lagging behind flag rollout.","solutions":["Enable the feature flag: in Rails console `Account.root_lti_context_of(...)`/account.feature_flags - or SiteAdmin/account UI: enable `:peer_review_allocation_and_grading`.","Via console: `account.enable_feature! :peer_review_allocation_and_grading` (or set flag state to 'on' for the specific sub-account).","Check `assignment.context.feature_enabled?(:peer_review_allocation_and_grading)` before calling peer review APIs and surface a friendly message."],"exampleFix":"// before\nPeerReview::SubAssignmentCreator.new(assignment: assignment).call # flag off\n// after\n# enable in account console first:\n# account.set_feature_flag!(Feature::Flag.new(feature: :peer_review_allocation_and_grading, state: 'on'))\nPeerReview::SubAssignmentCreator.new(assignment: assignment).call","handlingStrategy":"validation","validationCode":"unless assignment.context.feature_enabled?(:peer_review_allocation_and_grading)\n  return render json: { error: \"feature disabled\" }, status: :forbidden\nend","typeGuard":null,"tryCatchPattern":"begin\n  service.call\nrescue PeerReview::FeatureDisabledError => e\n  render json: { error: e.message }, status: :forbidden\nend","preventionTips":["Enable :peer_review_allocation_and_grading on target accounts before rollout","Gate API endpoints and UI behind the same feature_enabled? check","Document flag requirements in onboarding/runbooks"],"tags":["peer-review","feature-flag","rails","configuration"],"backgroundTag":"feature-not-enabled","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"}