{"record":{"id":"cf0c268f9dd89ead","repo":"instructure/canvas-lms","slug":"invalid-restriction-type","errorCode":null,"errorMessage":"invalid restriction type","messagePattern":"invalid restriction type","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"app/models/master_courses/restrictor.rb","lineNumber":63,"sourceCode":"\n    klass.after_update :mark_downstream_changes\n\n    # luckily before_update comes after before_save in case we do sneaky changes in models\n    klass.before_update :check_before_overwriting_child_content_on_import\n  end\n\n  module CommonMethods # i didn't want to copypaste all this into the collection one\n    def self.included(klass)\n      klass.cattr_accessor :restricted_column_settings\n      klass.restricted_column_settings = {}\n\n      klass.extend ClassMethods\n      klass.validate :check_for_restricted_column_changes\n    end\n\n    module ClassMethods\n      def restrict_columns(edit_type, columns)\n        raise \"invalid restriction type\" unless MasterCourses::LOCK_TYPES.include?(edit_type)\n\n        columns = Array(columns).map(&:to_s)\n        current = restricted_column_settings[edit_type] || []\n        restricted_column_settings[edit_type] = (current + columns).uniq\n      end\n\n      def restrict_assignment_columns\n        restrict_columns :settings, %i[assignment_group_id\n                                       grading_type\n                                       omit_from_final_grade\n                                       submission_types\n                                       group_category\n                                       group_category_id\n                                       grade_group_students_individually\n                                       peer_reviews\n                                       moderated_grading\n                                       peer_reviews_due_at\n                                       allowed_attempts]","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/master_courses/restrictor.rb#L45-L81","documentation":"MasterCourses::Restrictor.restrict_columns validates that edit_type is one of MasterCourses::LOCK_TYPES (e.g. :content, :state, :points, :due_dates, :availability, :settings). Passing any other symbol raises 'invalid restriction type' before any columns are recorded.","triggerScenarios":"Calling restrict_columns(:some_edit_type, :col) with a symbol not in MasterCourses::LOCK_TYPES, often a typo or an invented restriction category, from a model's restrict_*_columns helper (e.g. restrict_assignment_columns).","commonSituations":"Typo like :attributes instead of :content; adding a custom edit type without registering it in LOCK_TYPES; upgrading Canvas where a lock type was renamed.","solutions":["Use only lock types in MasterCourses::LOCK_TYPES (check lib/master_courses.rb)","Fix the symbol typo in the restrict_columns call","If a new category is genuinely needed, add it to MasterCourses::LOCK_TYPES and handle it in downstream code"],"exampleFix":"// before\nrestrict_columns(:attributes, [:title])\n// after\nrestrict_columns(:content, [:title])","handlingStrategy":"validation","validationCode":"raise ArgumentError unless MasterCourses::LOCK_TYPES.include?(edit_type)\nrestrict_columns(edit_type, columns)","typeGuard":"def valid_lock_type?(t)\n  MasterCourses::LOCK_TYPES.include?(t.to_sym)\nend","tryCatchPattern":"begin\n  model.restrict_columns(edit_type, cols)\nrescue RuntimeError => e\n  raise unless e.message == 'invalid restriction type'\n  Rails.logger.warn(\"bad edit type #{edit_type}\")\nend","preventionTips":["Centralize valid lock types in a constant and reference it everywhere","Lint custom model concerns against MasterCourses::LOCK_TYPES"],"tags":["ruby","blueprint-courses","invalid-argument"],"backgroundTag":"invalid-enum-value","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"}