{"record":{"id":"9ecbb64b87df67a4","repo":"instructure/canvas-lms","slug":"a-cross-listing-referenced-a-non-existent-section-section-id","errorCode":null,"errorMessage":"A cross-listing referenced a non-existent section #{section_id}","messagePattern":"A cross-listing referenced a non-existent section #(.+?)","errorType":"validation","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/xlist_importer.rb","lineNumber":59,"sourceCode":"\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\n            @course.start_at = section.course.start_at\n            @course.conclude_at = section.course.conclude_at\n            @course.restrict_enrollments_to_course_dates = section.course.restrict_enrollments_to_course_dates\n            @course.sis_source_id = xlist_course_id\n            @course.sis_batch_id = @batch.id\n            @course.workflow_state = \"claimed\"","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/xlist_importer.rb#L41-L77","documentation":"The importer looks up the section by sis_source_id under the root account (CourseSections) and raises ImportError when no section matches. The cross-listing cannot proceed because the target section record does not exist in Canvas yet or its SIS ID differs.","triggerScenarios":"add_crosslist is called with a section_id whose sis_source_id has no matching CourseSection in the root account — the section was never imported, was imported under a different SIS ID, or belongs to a different root account/subaccount.","commonSituations":"Crosslist.csv processed before sections.csv in the same SIS batch or a previous batch failed; section SIS IDs renamed upstream; importing into the wrong root account; sections deleted in Canvas but still present in the SIS export.","solutions":["Import the sections (sections.csv) before or in the same batch as crosslist.csv","Verify the section_id matches the section's sis_source_id exactly (no typos, no stale IDs)","Confirm the import is running against the correct root_account that contains the section","Re-run the section import to recreate missing sections, then retry the crosslist import"],"exampleFix":"# before (ordering)\n# crosslist.csv imported standalone\n# after\n# import sections.csv first, then crosslist.csv in the same sis batch","handlingStrategy":"validation","validationCode":"section = root_account.course_sections.find_by(sis_source_id: section_id)\nraise \"Section #{section_id} not found; import sections first\" unless section","typeGuard":null,"tryCatchPattern":"begin\n  xlist.add_crosslist(xlist_course_id, section_id, status)\nrescue SIS::ImportError => e\n  if e.message =~ /non-existent section/\n    Rails.logger.error(\"Re-run sections.csv import; missing section #{section_id}\")\n  end\nend","preventionTips":["Always import sections.csv before crosslist.csv in the same batch","Verify SIS IDs against the source system before export","Ensure the batch runs against the root account that owns the sections","Diff SIS IDs between exports to catch renames"],"tags":["sis","import","record-not-found","cross-listing"],"backgroundTag":"record-not-found","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"}