instructure/canvas-lms · error · ImportError
No account_id given for an account
Error message
No account_id given for an account
What it means
The SIS account importer requires a non-blank account_id (the SIS source id) for every account row. add_account raises ImportError when account_id is blank because an account without an identifier cannot be looked up or created. This is a fail-fast guard at the top of the method before any parent lookup happens.
Solutions
- Supply a non-blank account_id for the account row in the SIS CSV.
- Remove rows that represent the root account — it is identified by the batch's root_account, not by SIS import.
- Verify CSV parsing preserves the account_id column (check header name and delimiter).
Example fix
// before
add_account('', 'parent1', 'active', 'Sub Account', nil)
// after
add_account('sub1', 'parent1', 'active', 'Sub Account', nil) Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, "account_id required" if account_id.to_s.strip.empty?
Try / catch
begin
importer.add_account(account_id, parent_id, status, name, integration_id)
rescue SIS::BaseImporter::ImportError => e
errors << {row: account_id, reason: e.message}
end Prevention
- Never include the root account row in accounts.csv
- Validate CSV headers and row completeness before import
- Reject blank ids during SIS CSV pre-processing
When it happens
Trigger: Calling AccountImporter::Importer#add_account(nil, parent_id, status, name, integration_id) or with '' / whitespace-only account_id. Also occurs when the SIS accounts CSV has an empty account_id cell.
Common situations: Malformed SIS accounts.csv with missing account_id column value; CSV parsing that drops empty fields; generator scripts omitting the id for the root-level row (root account should not be in the SIS file at all).
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 name given for account #
- No status given for #
- No # _id given for a # .
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/dcea6ff45c4a4235.
Report an issue: GitHub.
Appendix: source
Thrown at lib/sis/account_importer.rb:52
importer.success_count
end
class Work
attr_reader :success_count, :accounts_to_set_sis_batch_ids, :roll_back_data
def initialize(batch, root_account, logger)
@batch = batch
@root_account = root_account
@accounts_cache = {}
@roll_back_data = []
@logger = logger
@success_count = 0
@accounts_to_set_sis_batch_ids = Set.new
end
def add_account(account_id, parent_account_id, status, name, integration_id)
raise ImportError, "No account_id given for an account" if account_id.blank?
return if @batch.skip_deletes? && status =~ /deleted/i
parent = nil
unless parent_account_id.blank?
parent = @accounts_cache[parent_account_id]
parent ||= @root_account.all_accounts.find_by(sis_source_id: parent_account_id)
raise ImportError, "Parent account didn't exist for #{account_id}" unless parent
raise ImportError, "Cannot restore sub_account with ID: #{account_id} because parent_account with ID: #{parent_account_id} has been deleted." if parent.workflow_state == "deleted"
@accounts_cache[parent.sis_source_id] = parent
end
account = @accounts_cache[account_id]
account ||= @root_account.all_accounts.find_by(sis_source_id: account_id)
if account.nil?
raise ImportError, "No name given for account #{account_id}, skipping" if name.blank?
raise ImportError, "Improper status \"#{status}\" for account #{account_id}, skipping" unless /\A(active|deleted)/i.match?(status)
endView on GitHub (pinned to 1c9f0bb801)