{"record":{"id":"e07dff7b3db6607f","repo":"instructure/canvas-lms","slug":"not-importing-academic-benchmark-data-because-no-user-id-set","errorCode":null,"errorMessage":"Not importing academic benchmark data because no user id set","messagePattern":"Not importing academic benchmark data because no user id set","errorType":"exception","errorClass":"Canvas::Migration::Error","httpStatus":null,"severity":"error","filePath":"gems/plugins/academic_benchmark/lib/academic_benchmark.rb","lineNumber":212,"sourceCode":"    end\n  end\n\n  def self.ensure_partner_key\n    unless AcademicBenchmark.config[:partner_key].present?\n      \"Partner key is not set\"\n    end\n  end\n\n  def self.authorized?\n    check_for_import_rights(\n      user: ensure_real_user(user_id: ensure_user_id_set)\n    )\n  end\n\n  def self.ensure_user_id_set\n    uid = Setting.get(\"academic_benchmark_migration_user_id\", nil)\n    unless uid.present?\n      raise Canvas::Migration::Error,\n            \"Not importing academic benchmark data because no user id set\"\n    end\n    uid\n  end\n\n  def self.ensure_real_user(user_id:)\n    u = User.find_by(id: user_id)\n    unless u\n      raise Canvas::Migration::Error,\n            \"Not importing academic benchmark data because no user found matching id '#{user_id}'\"\n    end\n    u\n  end\n\n  def self.check_for_import_rights(user:)\n    unless Account.site_admin.grants_right?(user, :manage_global_outcomes)\n      raise Canvas::Migration::Error,\n            \"Not importing academic benchmark data because user with ID \" \\","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/gems/plugins/academic_benchmark/lib/academic_benchmark.rb#L194-L230","documentation":"Academic Benchmark migrations must attribute imports to a real user id stored in the `academic_benchmark_migration_user_id` setting. ensure_user_id_set raises Canvas::Migration::Error when this setting is absent/blank, since imports cannot proceed without a valid owning user.","triggerScenarios":"Enqueuing or running an AB content migration when the root account Setting `academic_benchmark_migration_user_id` is unset or empty.","commonSituations":"Fresh installs or new shards where the setting was never seeded; the configured migration user was deleted and the setting cleared; multi-tenant setups where only some accounts have the setting.","solutions":["Set the setting: `Setting.set('academic_benchmark_migration_user_id', <existing active user id>)` on the relevant shard/root account","Pick an admin user as the migration user and persist their id","Re-create the setting if it was lost during environment migration","Check `Setting.get('academic_benchmark_migration_user_id', nil)` in console before running imports"],"exampleFix":"// console\n# before\nSetting.get('academic_benchmark_migration_user_id', nil) # => nil\n// after\nadmin = Account.site_admin.admin_users.first\nSetting.set('academic_benchmark_migration_user_id', admin.id)","handlingStrategy":"validation","validationCode":"uid = Setting.get('academic_benchmark_migration_user_id', nil)\nraise 'migration user id not set' unless uid.present?","typeGuard":null,"tryCatchPattern":"begin\n  AcademicBenchmark.import(...)\nrescue Canvas::Migration::Error => e\n  raise unless e.message.include?('no user id set')\n  Rails.logger.error('Seed academic_benchmark_migration_user_id')\nend","preventionTips":["Seed the setting on every shard at provisioning","Point it at a durable admin/service account","Re-verify after user cleanup scripts"],"tags":["academic-benchmark","settings","missing-config","migration"],"backgroundTag":"missing-config-value","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"}