instructure/canvas-lms · error · ImportError

No # given for a # user

Error message

No #{is_tags ? "tag_id" : "group_id"} given for a #{is_tags ? "differentiation tag" : "group"} user

What it means

add_group_membership requires an identifier of the group (or differentiation tag) to attach the user to. When the group_id field is blank, ImportError is raised with tag-specific wording when is_tags is true.

Solutions

  1. Populate group_id (or tag_id for is_tags rows) in the CSV/import call
  2. Trim/normalize the cell so a value like ' ' is not treated as missing... ensure a real sis_source_id is present
  3. Skip rows that legitimately have no group (they should not be submitted as membership rows)
  4. Fix the upstream export that omitted the identifier

Example fix

# before
"u_1,,accepted"   # missing group_id
# after
"u_1,g_456,accepted"
Defensive patterns

Strategy: validation

Validate before calling

raise 'blank group_id' if row['group_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 (tag_id|group_id) given/
  skipped << row # log and continue with other rows
end

Prevention

When it happens

Trigger: add_group_membership called (directly or via SIS enrollments/groups CSV processing) with group_id nil or empty string; with is_tags: true the field should hold the tag's sis_source_id but is missing.

Common situations: Groups CSV row missing group_id column; differentiation-tag membership CSV missing tag_id; whitespace-only cell; upstream data export dropped the column.

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


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/afcb5d686c13dcc1. Report an issue: GitHub.

Appendix: source

Thrown at lib/sis/group_membership_importer.rb:46

      importer.success_count
    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)