instructure/canvas-lms · error

Invalid version (# ) specified!

Error message

Invalid version (#{version.inspect}) specified!

What it means

simply_versioned's versioning options validate the :limit/:when combination passed to simply_versioned. Raising 'Invalid version (X) specified!' means the version spec supplied (e.g. a number of versions or a hash like unmodified: n) did not match any accepted shape. It is an argument validation error at model class-definition/load time.

Solutions

  1. Read the inspect-ed value in the message and compare against documented :when/:limit options in simply_versioned.rb
  2. Fix the model's simply_versioned call to use the accepted option shapes (e.g. when: {unmodified: 30.minutes})
  3. Pin/upgrade the gem to match the syntax your models use
  4. Add a spec that boots the model class to catch config regressions early

Example fix

// before
simply_versioned when: 5
// after
simply_versioned when: {unmodified: 30.minutes}
Defensive patterns

Strategy: validation

Validate before calling

valid = opts[:when].is_a?(Hash) && (opts[:when][:unmodified] || opts[:when][:maximum])
raise ArgumentError, 'bad simply_versioned options' unless valid || opts.empty?

Type guard

def valid_version_opts?(o)
  o.is_a?(Hash) && (o[:when].nil? || o[:when].is_a?(Hash))
end

Prevention

When it happens

Trigger: Declaring simply_versioned in a model with a malformed :when option (e.g. simply_versioned when: 5 without required keys, or an unsupported value type) at class load time.

Common situations: Upgrading the simply_versioned gem and old option syntax no longer accepted; typos in the when/limit hash keys; copying configuration from an incompatible gem version.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at gems/simply_versioned/lib/simply_versioned.rb:146

def revert_to_version(version, options = {})
  options.reverse_merge!({
    except: [:created_at, :updated_at]
  })

  version = case version
            when Version
              version
            when Integer
              versions.where(number: version).first
            end

  raise "Invalid version (#{version.inspect}) specified!" unless version

  options[:except] = options[:except].map(&:to_s)

  update(YAML.load(version.yaml).except(*options[:except]))
  (options[:versioned_associations] || DEFAULTS[:versioned_associations]).each do |va|
    restore_associations_from_version(version, va)
  end
end

View on GitHub (pinned to 1c9f0bb801)