instructure/canvas-lms · error · ImportError

A section did not pass validation

Error message

A section did not pass validation (section: #{section_id} / #{name}, course: #{course_id}, error: #{section.errors.full_messages.join(", ")})

What it means

Save-failure path in SIS::SectionImporter::Work#add_section: the CourseSection failed model validation (section.valid? false or save failed), so ImportError is raised with the section's full error messages, identifying section/name/course and the validation errors.

Solutions

  1. Read the embedded validation messages and fix the row values (e.g. duplicate sis id, bad dates)
  2. Re-run the SIS batch after correction
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/sis/section_importer.rb:156 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/9a698f26eb3f674c. Report an issue: GitHub.

Appendix: source

Thrown at lib/sis/section_importer.rb:156

        if section.changed?
          if section.workflow_state_changed? &&
             section.workflow_state_was == "deleted" &&
             section.default_section? &&
             CourseSection.active.where(course_id: section.course_id, default_section: true).exists?
            # trying to restore a previously default section but there's one already so undefault the restored one
            section.default_section = false
          end
          section.sis_batch_id = @batch.id
          if section.valid?
            section.save
            data = SisBatchRollBackData.build_data(sis_batch: @batch, context: section)
            @roll_back_data << data if data
          else
            msg = "A section did not pass validation "
            msg += "(" + "section: #{section_id} / #{name}, course: #{course_id}, error: "
            msg += section.errors.full_messages.join(", ") + ")"
            raise ImportError, msg
          end
        else
          @sections_to_update_sis_batch_ids << section.id
        end

        @success_count += 1
      end
    end
  end
end

View on GitHub (pinned to 1c9f0bb801)