instructure/canvas-lms · error · Canvas::Migration::Error

Missing required content_migration settings

Error message

Missing required content_migration settings

What it means

Canvas::Migration::Error raised at the start of AcademicBenchmark::Converter#export when @content_migration is nil. The converter requires a content_migration object both to attribute the import to a user and to store results; without it export cannot proceed.

Solutions

  1. Pass a persisted ContentMigration into the converter settings: { content_migration: cm, ... }.
  2. Use the standard migration pipeline (ContentMigration job) so content_migration is set automatically.
  3. In tests, stub or build a ContentMigration record instead of omitting the key.
  4. Guard before export: raise early if settings[:content_migration].nil?.

Example fix

// before
converter = AcademicBenchmark::Converter.new(partner_id: pid, partner_key: key)
converter.export
// after
cm = ContentMigration.create!(context: Account.site_admin, user: admin)
converter = AcademicBenchmark::Converter.new({ content_migration: cm, partner_id: pid, partner_key: key })
converter.export
Defensive patterns

Strategy: validation

Validate before calling

raise ArgumentError, 'content_migration required' unless settings[:content_migration]

Try / catch

begin
  converter.export
rescue Canvas::Migration::Error => e
  Rails.logger.error("academic benchmark export failed: #{e.message}")
  cm.fail!
end

Prevention

When it happens

Trigger: Instantiating AcademicBenchmark::Converter with settings lacking a content_migration (the settings hash must include content_migration or be constructed via with_content_migration) and then calling export.

Common situations: Custom scripts or jobs constructing the converter directly without wiring a ContentMigration; refactors dropping the content_migration setting; test harnesses building a bare settings hash.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at gems/plugins/academic_benchmark/lib/academic_benchmark/converter.rb:34

#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.

require "academic_benchmarks"

module AcademicBenchmark
  class Converter < Canvas::Migration::Migrator
    def initialize(settings = {})
      super(settings, "academic_benchmark")
      @ratings_overrides = settings[:migration_options] || {}
      @course[:learning_outcomes] = []
      @partner_id = settings[:partner_id]
      @partner_key = settings[:partner_key]
    end

    def export
      unless content_migration
        raise Canvas::Migration::Error,
              "Missing required content_migration settings"
      end
      unless Account.site_admin.grants_right?(content_migration.user, :manage_global_outcomes)
        raise Canvas::Migration::Error,
              "User isn't allowed to edit global outcomes"
      end
      unless @archive_file
        unless @partner_id.present? || AcademicBenchmark.ensure_partner_id.nil?
          raise Canvas::Migration::Error, I18n.t("A partner ID is required to use Academic Benchmarks")
        end
        unless @partner_key.present? || AcademicBenchmark.ensure_partner_key.nil?
          raise Canvas::Migration::Error, I18n.t("A partner key is required to use Academic Benchmarks")
        end
      end
      if outcome_data.present?
        if outcome_data.instance_of? AcademicBenchmarks::Standards::StandardsForest
          outcome_data.trees.each do |t|
            @course[:learning_outcomes] << t.root.build_outcomes(@ratings_overrides)

View on GitHub (pinned to 1c9f0bb801)