{"record":{"id":"5ab62e3569e8d170","repo":"instructure/canvas-lms","slug":"no-course-id-given-for-a-section-section-id","errorCode":null,"errorMessage":"No course_id given for a section #{section_id}","messagePattern":"No course_id given for a section #(.+?)","errorType":"validation","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/section_importer.rb","lineNumber":82,"sourceCode":"        :course_ids_to_update_associations,\n        :deleted_section_ids,\n        :roll_back_data\n      )\n\n      def initialize(batch, root_account, logger)\n        @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","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/section_importer.rb#L64-L100","documentation":"Validation guard in SectionImporter::Work#add_section raised when the course_id argument is blank for a section that does have a section_id. A section must belong to a course; the missing parent identifier causes the row to be rejected at parse time.","triggerScenarios":"Thrown at lib/sis/section_importer.rb:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a valid course_id to each section row","Ensure the course exists/is imported before its sections"],"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"}