{"record":{"id":"60869f5f87947ce4","repo":"instructure/canvas-lms","slug":"error-checking-syllabus-versioning-flag-e-message","errorCode":null,"errorMessage":"Error checking syllabus_versioning flag: #{e.message}","messagePattern":"Error checking syllabus_versioning flag: #(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/models/course.rb","lineNumber":425,"sourceCode":"\n  def save_original_syllabus_version_if_needed\n    return unless @should_save_original_syllabus_version\n\n    original_attributes = attributes.merge(\"syllabus_body\" => syllabus_body_previously_was)\n    versions.create(yaml: original_attributes.except(*simply_versioned_options[:exclude]).to_yaml)\n  rescue => e\n    Rails.logger.warn(\"Error saving original syllabus version: #{e.message}\")\n  end\n\n  simply_versioned exclude: SIMPLY_VERSIONED_EXCLUDE_FIELDS,\n                   keep: 5,\n                   when: lambda { |course|\n                     return false unless course.syllabus_body_changed?\n\n                     begin\n                       !!course.account&.feature_enabled?(:syllabus_versioning)\n                     rescue => e\n                       Rails.logger.warn(\"Error checking syllabus_versioning flag: #{e.message}\")\n                       false\n                     end\n                   },\n                   on_create: lambda { |course, version|\n                     if course.updating_user\n                       begin\n                         yaml_data = YAML.safe_load(version.yaml, permitted_classes: [Time, Date, Symbol, ActiveSupport::TimeWithZone, ActiveSupport::TimeZone])\n                         yaml_data[\"user_id\"] = course.updating_user.id\n                         version.yaml = yaml_data.to_yaml\n                         version.save\n                       rescue => e\n                         Rails.logger.error(\"Failed to add user_id to course version: #{e.message}\")\n                       end\n                     end\n                   },\n                   versioned_associations: [:attachment_associations]\n\n  include StickySisFields","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/course.rb#L407-L443","documentation":"The Course versioning :when lambda decides whether a syllabus change should create a version by checking the account's syllabus_versioning feature flag. If course.account or the feature lookup raises, this warning is logged and the lambda returns false, silently skipping version creation.","triggerScenarios":"During any course save with syllabus_body changed, the feature_enabled?(:syllabus_versioning) check throws — typically account load failure, root account lookup on a fragment/shard issue, or a feature-flag registry error.","commonSituations":"Multi-shard environments where the account lives on a different shard; deleted or detached root account; errors raised by feature-flag plugins; DB connectivity blips during saves.","solutions":["Check the log for the underlying exception message and fix the account/feature lookup root cause","Verify the course's account/root_account chain is intact (account not deleted, correct shard)","Confirm the syllabus_versioning feature flag is registered and defined in the Canvas feature registry","Add retry/rescue hardening if transient DB issues cause frequent skips"],"exampleFix":"// before\n!!course.account&.feature_enabled?(:syllabus_versioning)\n// after\naccount = course.account&.root_account || course.account\naccount ? !!account.feature_enabled?(:syllabus_versioning) : false","handlingStrategy":"fallback","validationCode":"flag_on = begin\n  !!course.account&.feature_enabled?(:syllabus_versioning)\nrescue\n  false\nend","typeGuard":"def versioning_account?(course)\n  acct = course.account&.root_account || course.account\n  acct.respond_to?(:feature_enabled?) && acct.feature_enabled?(:syllabus_versioning)\nend","tryCatchPattern":"begin\n  versioning = !!account.feature_enabled?(:syllabus_versioning)\nrescue => e\n  Rails.logger.warn(\"flag check failed: #{e.message}\")\n  versioning = false\nend","preventionTips":["Ensure the syllabus_versioning flag is registered in the feature registry","Verify account/root_account integrity on all shards","Log and alert on repeated flag-check failures","Test course saves with the flag both enabled and disabled"],"tags":["feature-flags","versions","syllabus","courses"],"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"}