{"record":{"id":"afcb5d686c13dcc1","repo":"instructure/canvas-lms","slug":"no-is-tags-tag-id-group-id-given-for-a-is-tags","errorCode":null,"errorMessage":"No #{is_tags ? \"tag_id\" : \"group_id\"} given for a #{is_tags ? \"differentiation tag\" : \"group\"} user","messagePattern":"No #(.+?) given for a #(.+?) user","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/group_membership_importer.rb","lineNumber":46,"sourceCode":"      importer.success_count\n    end\n\n    class Work\n      attr_accessor :success_count, :roll_back_data\n\n      def initialize(batch, root_account, logger)\n        @batch = batch\n        @root_account = root_account\n        @logger = logger\n        @success_count = 0\n        @groups_cache = {}\n        @roll_back_data = []\n      end\n\n      def add_group_membership(user_id, group_id, status, is_tags: false)\n        user_id = user_id.to_s\n        group_id = group_id.to_s\n        raise ImportError, \"No #{is_tags ? \"tag_id\" : \"group_id\"} given for a #{is_tags ? \"differentiation tag\" : \"group\"} user\" if group_id.blank?\n        raise ImportError, \"No user_id given for a #{is_tags ? \"differentiation tag\" : \"group\"} user\" if user_id.blank?\n        raise ImportError, \"Improper status \\\"#{status}\\\" for a #{is_tags ? \"differentiation tag\" : \"group\"} user\" unless /\\A(accepted|deleted)/i.match?(status)\n        return if @batch.skip_deletes? && status =~ /deleted/i\n\n        pseudo = @root_account.pseudonyms.find_by(sis_user_id: user_id)\n        user = pseudo&.user\n\n        group = @groups_cache[group_id]\n        scope = is_tags ? @root_account.all_differentiation_tags : @root_account.all_groups\n        group ||= scope.where(sis_source_id: group_id).preload(:context).take\n        @groups_cache[group.sis_source_id] = group if group\n\n        raise ImportError, \"User #{user_id} didn't exist for #{is_tags ? \"differentiation tag\" : \"group\"} user\" unless user\n        raise ImportError, \"#{is_tags ? \"Differentiation tag\" : \"Group\"} #{group_id} didn't exist for #{is_tags ? \"differentiation tag\" : \"group\"} user\" unless group\n\n        if group.context.is_a?(Course) && !group.context.all_real_users.where(id: user.id).exists?\n          raise ImportError, \"User #{user_id} doesn't have an enrollment in the course of #{is_tags ? \"differentiation tag\" : \"group\"} #{group_id}.\"\n        end","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/group_membership_importer.rb#L28-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"Groups CSV row missing group_id column; differentiation-tag membership CSV missing tag_id; whitespace-only cell; upstream data export dropped the column.","solutions":["Populate group_id (or tag_id for is_tags rows) in the CSV/import call","Trim/normalize the cell so a value like ' ' is not treated as missing... ensure a real sis_source_id is present","Skip rows that legitimately have no group (they should not be submitted as membership rows)","Fix the upstream export that omitted the identifier"],"exampleFix":"# before\n\"u_1,,accepted\"   # missing group_id\n# after\n\"u_1,g_456,accepted\"","handlingStrategy":"validation","validationCode":"raise 'blank group_id' if row['group_id'].to_s.strip.empty?","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_group_membership(uid, gid, status)\nrescue SIS::GroupImporter::ImportError => e\n  raise unless e.message =~ /No (tag_id|group_id) given/\n  skipped << row # log and continue with other rows\nend","preventionTips":["Validate the CSV has non-empty group_id/tag_id on every membership row","Trim cells and treat whitespace-only as invalid at export time","Add a lint step that rejects membership rows missing identifiers"],"tags":["sis-import","groups","missing-argument","csv"],"backgroundTag":"missing-required-argument","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}