instructure/canvas-lms · error · ImportError
No user_id given for admin
Error message
No user_id given for admin
What it means
The SIS admin importer's process_admin requires a user_id identifying which user receives the admin role. A blank user_id raises ImportError immediately. Admins are always defined by pairing an existing user with an account and role, so the user reference is mandatory.
Solutions
- Populate user_id in admins.csv with the user's sis_user_id (matching a previously imported user).
- Skip blank CSV rows before feeding the importer.
- Import the users first so a valid user_id exists, then import admins.
Example fix
// before process_admin(user_id: '', account_id: 'acct1', role: 'AdminEnrollment', status: 'active') // after process_admin(user_id: 'user123', account_id: 'acct1', role: 'AdminEnrollment', status: 'active')
Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, "user_id required" if user_id.to_s.strip.empty? raise "unknown user" unless root_account.users.exists?(sis_user_id: user_id) # or pseudographs lookup
Try / catch
begin
importer.process_admin(user_id: uid, account_id: aid, role: role, status: status)
rescue SIS::BaseImporter::ImportError => e
logger.warn("skipping admin row: #{e.message}")
end Prevention
- Import users.csv before admins.csv
- Skip empty CSV rows
- Require user_id column non-null in SIS export validation
When it happens
Trigger: process_admin(user_id: nil/''/whitespace, ...) or an admins.csv row with an empty user_id (sis_user_id / integrated data column empty).
Common situations: SIS export not populating the user_id column; user identified by email/login instead of sis id without prior user import; blank rows at end of CSV being processed.
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
- Improper status "# " for abstract course #
- Improper status "# " for # # , skipping
- No account_id given for an account
- No name given for account #
- No status given for #
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/dbdd0b21553232ae.
Report an issue: GitHub.
Appendix: source
Thrown at lib/sis/admin_importer.rb:63
attr_accessor :success_count,
:roll_back_data,
:account_users_to_update_associations,
:account_users_to_set_batch_id
def initialize(batch, root_account, logger)
@batch = batch
@root_account = root_account
@account = root_account
@logger = logger
@success_count = 0
@roll_back_data = []
@account_users_to_update_associations = Set.new
@account_users_to_set_batch_id = Set.new
@account_roles_by_account_id = {}
end
def process_admin(user_id: nil, account_id: nil, role_id: nil, role: nil, status: nil, root_account: nil)
raise ImportError, "No user_id given for admin" if user_id.blank?
raise ImportError, "No status given for admin" if status.blank?
raise ImportError, "No role_id or role given for admin" if role.blank? && role_id.blank?
state = status.downcase.strip
raise ImportError, "Invalid status #{status} for admin" unless %w[active deleted].include? state
return if @batch.skip_deletes? && state == "deleted"
get_account(account_id)
raise ImportError, "Invalid account_id given for admin" unless @account
get_role(role_id, role)
raise ImportError, "Invalid role '#{role}' for admin" if role.present? && !@role
raise ImportError, "Invalid role_id '#{role_id}' for admin" if role_id.present? && !@role
the_root_account = root_account_from_id(root_account) if root_account
raise ImportError, "Invalid or unknown user_id '#{user_id}' for admin" if root_account && !the_root_account
the_root_account ||= @root_accountView on GitHub (pinned to 1c9f0bb801)