instructure/canvas-lms · error · Canvas::Migration::Error
Not importing academic benchmark data because no user found…
Error message
Not importing academic benchmark data because no user found matching id '#{user_id}' What it means
Canvas::Migration::Error raised by AcademicBenchmark.ensure_real_user when User.find_by(id: user_id) returns nil, i.e. no User record exists for the id passed into an academic benchmark standards import. The gem refuses to run the import because every outcome import must be attributed to a real user who can be permission-checked.
Solutions
- Verify the user_id passed to the import exists: User.find_by(id: user_id) in the rails console.
- Fix the caller to resolve the actual importing user (e.g. from ContentMigration#user) instead of a stale id.
- If the user was deleted, re-run the import with a valid site-admin user.
- For cross-shard ids, ensure the id is a global id or that the lookup happens on the correct shard.
Example fix
// before AcademicBenchmark.import(user_id: params[:user_id]) // after user = User.find_by(id: params[:user_id]) raise ArgumentError, 'user not found' unless user AcademicBenchmark.import(user_id: user.id)
Defensive patterns
Strategy: validation
Validate before calling
user = User.find_by(id: user_id)
raise ArgumentError, "user #{user_id} not found" unless user
# then call AcademicBenchmark.import(user_id: user.id) Type guard
valid_user = ->(u) { u.is_a?(User) && u.persisted? } Try / catch
begin
AcademicBenchmark.import(user_id: user_id)
rescue Canvas::Migration::Error => e
Rails.logger.warn("benchmark import aborted: #{e.message}")
end Prevention
- Resolve the user from ContentMigration#user rather than caching ids in jobs.
- Guard jobs against deleted users before enqueueing.
- Use global ids for cross-shard lookups.
When it happens
Trigger: Calling AcademicBenchmark.import/ensure_real_user with a user_id that is nil, deleted, from another shard, or otherwise not present in the users table.
Common situations: Queued migration jobs referencing a user removed before the job ran; cross-shard user ids not resolvable; tests passing a fabricated id; a content_migration whose user_id setting was never set.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- A student referenced a non-existent user #
- Can't delete a non-existent observer for observer: #
- Do not look up MediaObjects by media_id - use the scope…
- # not found
- Enrollment # doesn't exist
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/12e03e7298e99254.
Report an issue: GitHub.
Appendix: source
Thrown at gems/plugins/academic_benchmark/lib/academic_benchmark.rb:221
def self.authorized?
check_for_import_rights(
user: ensure_real_user(user_id: ensure_user_id_set)
)
end
def self.ensure_user_id_set
uid = Setting.get("academic_benchmark_migration_user_id", nil)
unless uid.present?
raise Canvas::Migration::Error,
"Not importing academic benchmark data because no user id set"
end
uid
end
def self.ensure_real_user(user_id:)
u = User.find_by(id: user_id)
unless u
raise Canvas::Migration::Error,
"Not importing academic benchmark data because no user found matching id '#{user_id}'"
end
u
end
def self.check_for_import_rights(user:)
unless Account.site_admin.grants_right?(user, :manage_global_outcomes)
raise Canvas::Migration::Error,
"Not importing academic benchmark data because user with ID " \
"'#{user.id}' isn't allowed to edit global outcomes"
end
user
end
end
View on GitHub (pinned to 1c9f0bb801)