{"record":{"id":"1ba81e989906556e","repo":"instructure/canvas-lms","slug":"no-xlist-course-id-given-for-a-cross-listing","errorCode":null,"errorMessage":"No xlist_course_id given for a cross-listing","messagePattern":"No xlist_course_id given for a cross-listing","errorType":"validation","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/xlist_importer.rb","lineNumber":53,"sourceCode":"\n      importer.success_count\n    end\n\n    class Work\n      attr_accessor :success_count, :course_ids_to_update_associations\n\n      def initialize(batch, root_account, logger)\n        @batch = batch\n        @root_account = root_account\n        @logger = logger\n        @success_count = 0\n\n        @course = nil\n        @course_ids_to_update_associations = [].to_set\n      end\n\n      def add_crosslist(xlist_course_id, section_id, status)\n        raise ImportError, \"No xlist_course_id given for a cross-listing\" if xlist_course_id.blank?\n        raise ImportError, \"No section_id given for a cross-listing\" if section_id.blank?\n        raise ImportError, \"Improper status \\\"#{status}\\\" for a cross-listing\" unless /\\A(active|deleted)\\z/i.match?(status)\n        return if @batch.skip_deletes? && status =~ /deleted/i\n\n        section = @root_account.course_sections.find_by(sis_source_id: section_id)\n        raise ImportError, \"A cross-listing referenced a non-existent section #{section_id}\" unless section\n\n        unless @course && @course.sis_source_id == xlist_course_id\n          @course = @root_account.all_courses.find_by(sis_source_id: xlist_course_id)\n          if !@course && status =~ /\\Aactive\\z/i\n            # no course with this crosslist id found, make a new course,\n            # using the section's current course as a template\n            @course = Course.new\n            @course.root_account = @root_account\n            @course.account_id = section.course.account_id\n            @course.name = section.course.name\n            @course.course_code = section.course.course_code\n            @course.enrollment_term_id = section.course.enrollment_term_id","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/xlist_importer.rb#L35-L71","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fill in xlist_course_id with the sis_source_id of the destination course for every row in the xlist CSV.","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).","Fix column alignment — check for trailing/missing commas or shifted headers that leave the field empty.","Re-export from the source SIS ensuring the xlist_course_id column is populated and correctly ordered."],"exampleFix":"// before (bad CSV)\nsection_id,xlist_course_id,status\nsec1,,active\n\n// after\nsection_id,xlist_course_id,status\nsec1,course:math101,active","handlingStrategy":"validation","validationCode":"# pre-flight CSV validation\nrequire 'csv'\nCSV.foreach('section_xlist.csv', headers: true) do |row|\n  raise \"blank xlist_course_id on #{row['section_id']}\" if row['xlist_course_id'].to_s.strip.empty?\nend","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_crosslist(xlist_course_id, section_id, status)\nrescue SIS::ImportError => e\n  Rails.logger.warn(\"xlist row skipped: #{e.message}\")\nend","preventionTips":["Validate CSV headers and column counts before import","Never write empty strings for required SIS IDs in exports","Spot-check hand-edited CSVs for shifted/trailing commas","Lint SIS files with the official Canvas SIS import schema before upload"],"tags":["sis","import","missing-required-argument","ruby"],"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"}