instructure/canvas-lms · error · ImportError

No course_id given for #

Error message

No course_id given for #{type_display} #{sis_id}

What it means

Differentiation tag sets are always course-scoped. In find_context, when course_id is nil and type_display is 'differentiation tag set', the importer raises ImportError because there is no valid context (it cannot fall back to the root account) for a tag set.

Solutions

  1. Always populate course_id for differentiation tag set rows.
  2. Do not set account_id as a substitute — find_context is called with nil account_id for tag sets, so the value would be ignored and this error still raised.
  3. Split account-level group categories into a separate group_categorys.csv import.

Example fix

// before
dts-1,My Tag Set,,active  # course_id blank
// after
dts-1,My Tag Set,COURSE-42,active
Defensive patterns

Strategy: validation

Validate before calling

if row_type == 'differentiation tag set' && course_id.blank?
  raise ArgumentError, 'differentiation tag set rows require course_id'
end

Try / catch

begin
  importer.add_differentiation_tag_set(sis_id, course_id, name, status)
rescue SIS::GroupCategoryImporter::ImportError => e
  if e.message =~ /No course_id given/ then reject_row(sis_id, e.message)
  else raise end
end

Prevention

When it happens

Trigger: add_differentiation_tag_set(sis_id, nil, set_name, status) — i.e., a differentiation_tag_sets CSV row with a blank course_id column. add_group_category is unaffected because its type_display differs.

Common situations: Account-level export scripts reusing a group-category CSV template (which allows account_id) for tag sets; users assuming tag sets, like group categories, can live at the account level.

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/1ef77ca456281c31. Report an issue: GitHub.

Appendix: source

Thrown at lib/sis/group_category_importer.rb:75

          raise ImportError, "Only one context is allowed and both course_id and account_id where provided for #{type_display} #{sis_id}."
        end

        if account_id
          context = @accounts_cache[account_id]
          context ||= @root_account.all_accounts.active.find_by(sis_source_id: account_id)
          raise ImportError, "Account with id \"#{account_id}\" didn't exist for #{type_display} #{sis_id}" unless context

          @accounts_cache[context.sis_source_id] = context
        end

        if course_id
          context = @courses_cache[course_id]
          context ||= @root_account.all_courses.active.find_by(sis_source_id: course_id)
          raise ImportError, "Course with id \"#{course_id}\" didn't exist for #{type_display} #{sis_id}" unless context

          @courses_cache[context.sis_source_id] = context
        elsif course_id.nil? && type_display == "differentiation tag set"
          raise ImportError, "No course_id given for #{type_display} #{sis_id}"
        end

        context || @root_account
      end

      def check_context_movement(category, context, sis_id, type_display)
        if category && category.groups.active.exists? &&
           !(context.id == category.context_id && context.class.base_class.name == category.context_type)

          item_type = type_display.include?("tag") ? "tags" : "groups"

          raise ImportError, "Cannot move #{type_display} #{sis_id} because it has #{item_type} in it."
        end
      end

      def apply_status(category, status)
        case status
        when /active/i

View on GitHub (pinned to 1c9f0bb801)