instructure/canvas-lms · error · ImportError
No user_id given for a #
Error message
No user_id given for a #{is_tags ? "differentiation tag" : "group"} user What it means
Validation guard in GroupMembershipImporter::Work#add_group_membership raised when the user_id argument is blank. Because user_id is matched by both group membership and differentiation tag ingestion, the message names the entity kind ('differentiation tag' vs 'group') based on the is_tags flag. It fires at row-parse time, before any user lookup.
Solutions
- Populate user_id (the SIS user id) in each membership row
- Fix the upstream export to include the user's sis_user_id
- Skip or fix malformed rows before submitting the SIS batch
- Ensure you pass the user id, not an empty string, when calling add_group_membership directly
Example fix
# before "",g_456,accepted # after "u_100,g_456,accepted"
Defensive patterns
Strategy: validation
Validate before calling
raise 'blank user_id' if row['user_id'].to_s.strip.empty?
Try / catch
begin
importer.add_group_membership(uid, gid, status)
rescue SIS::GroupImporter::ImportError => e
raise unless e.message =~ /No user_id given/
Rails.logger.error("Membership row missing user_id")
end Prevention
- Require user_id column on every row of group user CSVs
- Fix upstream exports that drop empty user cells silently
- Pre-import lint to reject rows with blank user ids
When it happens
Trigger: add_group_membership called with nil/empty user_id; CSV row missing the user_id (or user's SIS ID) column.
Common situations: CSV missing user_id cell; export pipeline produced empty user column; calling the importer API directly without the user argument; using canvas user id where sis_user_id is expected so lookup also fails downstream.
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
- No # given for a # user
- Improper status "# " for a # user
- A # user did not pass validation (user: # , # : # , error…
- Cannot find # for ID: #
- Context is required, but none found
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/ed4a6f81543802fe.
Report an issue: GitHub.
Appendix: source
Thrown at lib/sis/group_membership_importer.rb:47
end
class Work
attr_accessor :success_count, :roll_back_data
def initialize(batch, root_account, logger)
@batch = batch
@root_account = root_account
@logger = logger
@success_count = 0
@groups_cache = {}
@roll_back_data = []
end
def add_group_membership(user_id, group_id, status, is_tags: false)
user_id = user_id.to_s
group_id = group_id.to_s
raise ImportError, "No #{is_tags ? "tag_id" : "group_id"} given for a #{is_tags ? "differentiation tag" : "group"} user" if group_id.blank?
raise ImportError, "No user_id given for a #{is_tags ? "differentiation tag" : "group"} user" if user_id.blank?
raise ImportError, "Improper status \"#{status}\" for a #{is_tags ? "differentiation tag" : "group"} user" unless /\A(accepted|deleted)/i.match?(status)
return if @batch.skip_deletes? && status =~ /deleted/i
pseudo = @root_account.pseudonyms.find_by(sis_user_id: user_id)
user = pseudo&.user
group = @groups_cache[group_id]
scope = is_tags ? @root_account.all_differentiation_tags : @root_account.all_groups
group ||= scope.where(sis_source_id: group_id).preload(:context).take
@groups_cache[group.sis_source_id] = group if group
raise ImportError, "User #{user_id} didn't exist for #{is_tags ? "differentiation tag" : "group"} user" unless user
raise ImportError, "#{is_tags ? "Differentiation tag" : "Group"} #{group_id} didn't exist for #{is_tags ? "differentiation tag" : "group"} user" unless group
if group.context.is_a?(Course) && !group.context.all_real_users.where(id: user.id).exists?
raise ImportError, "User #{user_id} doesn't have an enrollment in the course of #{is_tags ? "differentiation tag" : "group"} #{group_id}."
end
View on GitHub (pinned to 1c9f0bb801)