instructure/canvas-lms · warning

Error saving original syllabus version: #

Error message

Error saving original syllabus version: #{e.message}

What it means

When a course's syllabus is first versioned under the syllabus_versioning feature, save_original_syllabus_version_if_needed creates a Version from the previously-stored syllabus_body. Any exception during attributes/versions.create is swallowed, logged as this warning, and ignored so the save is not blocked — meaning the original syllabus snapshot may be lost.

Solutions

  1. Check the Rails log around this warning for the underlying exception and fix its root cause (DB error, data size)
  2. Verify the versions table is healthy/migrated on the course's shard
  3. Cap or sanitize oversized syllabus_body content before save
  4. After fixing, re-trigger a syllabus save to regenerate the missing original version

Example fix

// before
rescue => e
  Rails.logger.warn("Error saving original syllabus version: #{e.message}")
// after
rescue => e
  Rails.logger.warn("Error saving original syllabus version: #{e.message}")
  Canvas::Errors.capture(e, course_id: global_id) # surface to error reporting
Defensive patterns

Strategy: try-catch

Validate before calling

# before relying on the snapshot
raise 'versions table missing' unless course.connection.table_exists?(:versions)
course.versions # ensure versioning is functional

Try / catch

begin
  versions.create(yaml: attrs.to_yaml)
rescue => e
  Canvas::Errors.capture(e, course_id: global_id)
end

Prevention

When it happens

Trigger: @should_save_original_syllabus_version is set (first syllabus edit with syllabus_versioning enabled) and versions.create raises — DB error, serialization failure on oversized syllabus_body, or invalid YAML conversion of attributes.

Common situations: Very large syllabus bodies exceeding column/row limits; database connectivity issues; shard/replica problems during course save; migration drift in the versions table.

Related errors


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

Appendix: source

Thrown at app/models/course.rb:414

  before_save :check_if_should_save_original_syllabus_version
  after_save :save_original_syllabus_version_if_needed

  def check_if_should_save_original_syllabus_version
    @should_save_original_syllabus_version = syllabus_body_changed? &&
                                             syllabus_body_was.present? &&
                                             account&.feature_enabled?(:syllabus_versioning) &&
                                             unversioned?
  rescue
    @should_save_original_syllabus_version = false
  end

  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])

View on GitHub (pinned to 1c9f0bb801)