instructure/canvas-lms · error · ImportError

No xlist_course_id given for a cross-listing

Error message

No xlist_course_id given for a cross-listing

What it means

In the SIS cross-listing importer, add_crosslist validates its inputs before doing any lookup. If the xlist_course_id (the SIS ID of the course to cross-list INTO) is blank, there is nothing to cross-list to, so it raises ImportError immediately. The same guard pattern covers section_id and status on the next lines.

Solutions

  1. Fill in xlist_course_id with the sis_source_id of the destination course for every row in the xlist CSV.
  2. Validate the CSV before import: reject rows where xlist_course_id is nil/blank (e.g. with a pre-flight script using the CSV library).
  3. Fix column alignment — check for trailing/missing commas or shifted headers that leave the field empty.
  4. Re-export from the source SIS ensuring the xlist_course_id column is populated and correctly ordered.

Example fix

// before (bad CSV)
section_id,xlist_course_id,status
sec1,,active

// after
section_id,xlist_course_id,status
sec1,course:math101,active
Defensive patterns

Strategy: validation

Validate before calling

# pre-flight CSV validation
require 'csv'
CSV.foreach('section_xlist.csv', headers: true) do |row|
  raise "blank xlist_course_id on #{row['section_id']}" if row['xlist_course_id'].to_s.strip.empty?
end

Try / catch

begin
  importer.add_crosslist(xlist_course_id, section_id, status)
rescue SIS::ImportError => e
  Rails.logger.warn("xlist row skipped: #{e.message}")
end

Prevention

When it happens

Trigger: A section_xlist.csv (xlist) row with an empty xlist_course_id column — blank string, whitespace-only value, or a malformed CSV row where the column is missing so the parser passes nil.

Common situations: Hand-edited CSV exports with dropped columns, trailing commas shifting fields so xlist_course_id lands empty, export scripts that write empty strings for optional-looking columns, mis-mapped CSV headers during a tooling migration.

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

Appendix: source

Thrown at lib/sis/xlist_importer.rb:53

      importer.success_count
    end

    class Work
      attr_accessor :success_count, :course_ids_to_update_associations

      def initialize(batch, root_account, logger)
        @batch = batch
        @root_account = root_account
        @logger = logger
        @success_count = 0

        @course = nil
        @course_ids_to_update_associations = [].to_set
      end

      def add_crosslist(xlist_course_id, section_id, status)
        raise ImportError, "No xlist_course_id given for a cross-listing" if xlist_course_id.blank?
        raise ImportError, "No section_id given for a cross-listing" if section_id.blank?
        raise ImportError, "Improper status \"#{status}\" for a cross-listing" unless /\A(active|deleted)\z/i.match?(status)
        return if @batch.skip_deletes? && status =~ /deleted/i

        section = @root_account.course_sections.find_by(sis_source_id: section_id)
        raise ImportError, "A cross-listing referenced a non-existent section #{section_id}" unless section

        unless @course && @course.sis_source_id == xlist_course_id
          @course = @root_account.all_courses.find_by(sis_source_id: xlist_course_id)
          if !@course && status =~ /\Aactive\z/i
            # no course with this crosslist id found, make a new course,
            # using the section's current course as a template
            @course = Course.new
            @course.root_account = @root_account
            @course.account_id = section.course.account_id
            @course.name = section.course.name
            @course.course_code = section.course.course_code
            @course.enrollment_term_id = section.course.enrollment_term_id

View on GitHub (pinned to 1c9f0bb801)