{"record":{"id":"62228c436a8c6646","repo":"instructure/canvas-lms","slug":"section-section-id-references-course-course-id-which-doesn-t","errorCode":null,"errorMessage":"Section #{section_id} references course #{course_id} which doesn't exist","messagePattern":"Section #(.+?) references course #(.+?) which doesn't exist","errorType":"validation","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/section_importer.rb","lineNumber":88,"sourceCode":"        @batch = batch\n        @root_account = root_account\n        @logger = logger\n        @success_count = 0\n        @sections_to_update_sis_batch_ids = []\n        @roll_back_data = []\n        @course_ids_to_update_associations = Set.new\n        @deleted_section_ids = Set.new\n      end\n\n      def add_section(section_id, course_id, name, status, start_date = nil, end_date = nil, integration_id = nil)\n        raise ImportError, \"No section_id given for a section in course #{course_id}\" if section_id.blank?\n        raise ImportError, \"No course_id given for a section #{section_id}\" if course_id.blank?\n        raise ImportError, \"No name given for section #{section_id} in course #{course_id}\" if name.blank? && status =~ /\\Aactive/i\n        raise ImportError, \"Improper status \\\"#{status}\\\" for section #{section_id} in course #{course_id}\" unless /\\Aactive|\\Adeleted/i.match?(status)\n        return if @batch.skip_deletes? && status =~ /deleted/i\n\n        course = @root_account.all_courses.find_by(sis_source_id: course_id)\n        raise ImportError, \"Section #{section_id} references course #{course_id} which doesn't exist\" unless course\n\n        section = @root_account.course_sections.find_by(sis_source_id: section_id)\n        section ||= course.course_sections.where(sis_source_id: section_id).first_or_initialize\n        section.root_account = @root_account\n        # this is an easy way to load up the cache with data we already have\n        section.course = course if course.id == section.course_id\n\n        # only update the name on new records, and ones that haven't been changed since the last sis import\n        raise ImportError, \"No name given for section #{section_id} in course #{course_id}\" if name.blank? && section.new_record?\n\n        section.name = name if section.new_record? || (!section.stuck_sis_fields.include?(:name) && name.present?)\n\n        # update the course id if necessary\n        if section.course_id != course.id\n          if section.nonxlist_course_id\n            # this section is crosslisted\n            if (section.nonxlist_course_id != course.id && !section.stuck_sis_fields.include?(:course_id)) || (section.course.workflow_state == \"deleted\" && status.start_with?(\"active\"))\n              # but the course id we were given didn't match the crosslist info","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/section_importer.rb#L70-L106","documentation":"Referential-integrity error in SectionImporter::Work#add_section raised when the course_id supplied for the section passes the blank check but no matching course exists (or was not yet imported) in the root account. The section cannot be attached, so ingestion of the row fails.","triggerScenarios":"Thrown at lib/sis/section_importer.rb:88 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Import/verify the course before its sections in the SIS run","Confirm the course_id matches the course's sis_source_id"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}