instructure/canvas-lms · warning

Error checking syllabus_versioning flag: #

Error message

Error checking syllabus_versioning flag: #{e.message}

What it means

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.

Solutions

  1. Check the log for the underlying exception message and fix the account/feature lookup root cause
  2. Verify the course's account/root_account chain is intact (account not deleted, correct shard)
  3. Confirm the syllabus_versioning feature flag is registered and defined in the Canvas feature registry
  4. Add retry/rescue hardening if transient DB issues cause frequent skips

Example fix

// before
!!course.account&.feature_enabled?(:syllabus_versioning)
// after
account = course.account&.root_account || course.account
account ? !!account.feature_enabled?(:syllabus_versioning) : false
Defensive patterns

Strategy: fallback

Validate before calling

flag_on = begin
  !!course.account&.feature_enabled?(:syllabus_versioning)
rescue
  false
end

Type guard

def versioning_account?(course)
  acct = course.account&.root_account || course.account
  acct.respond_to?(:feature_enabled?) && acct.feature_enabled?(:syllabus_versioning)
end

Try / catch

begin
  versioning = !!account.feature_enabled?(:syllabus_versioning)
rescue => e
  Rails.logger.warn("flag check failed: #{e.message}")
  versioning = false
end

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/60869f5f87947ce4. Report an issue: GitHub.

Appendix: source

Thrown at app/models/course.rb:425

  def save_original_syllabus_version_if_needed
    return unless @should_save_original_syllabus_version

    original_attributes = attributes.merge("syllabus_body" => syllabus_body_previously_was)
    versions.create(yaml: original_attributes.except(*simply_versioned_options[:exclude]).to_yaml)
  rescue => e
    Rails.logger.warn("Error saving original syllabus version: #{e.message}")
  end

  simply_versioned exclude: SIMPLY_VERSIONED_EXCLUDE_FIELDS,
                   keep: 5,
                   when: lambda { |course|
                     return false unless course.syllabus_body_changed?

                     begin
                       !!course.account&.feature_enabled?(:syllabus_versioning)
                     rescue => e
                       Rails.logger.warn("Error checking syllabus_versioning flag: #{e.message}")
                       false
                     end
                   },
                   on_create: lambda { |course, version|
                     if course.updating_user
                       begin
                         yaml_data = YAML.safe_load(version.yaml, permitted_classes: [Time, Date, Symbol, ActiveSupport::TimeWithZone, ActiveSupport::TimeZone])
                         yaml_data["user_id"] = course.updating_user.id
                         version.yaml = yaml_data.to_yaml
                         version.save
                       rescue => e
                         Rails.logger.error("Failed to add user_id to course version: #{e.message}")
                       end
                     end
                   },
                   versioned_associations: [:attachment_associations]

  include StickySisFields

View on GitHub (pinned to 1c9f0bb801)