instructure/canvas-lms · error · ImportError

Improper status "# " for abstract course #

Error message

Improper status "#{status}" for abstract course #{abstract_course_id}

What it means

Canvas SIS abstract course importer validates that each abstract course row's 'status' column is 'active' or 'deleted'. If the value doesn't match /\Aactive|\Adeleted/i (case-insensitive prefix match at start of string), add_abstract_course raises ImportError. This guards against silently creating courses with an unrecognized workflow state from a malformed SIS CSV.

Solutions

  1. Check the SIS CSV 'status' column for the failing abstract_course_id and set it to exactly 'active' or 'deleted' (leading text matters; case is ignored).
  2. Strip whitespace/BOM from status before calling add_abstract_course.
  3. Map source-system statuses to Canvas's two allowed values before import.
  4. If the value is legitimately different, extend the regex in lib/sis/abstract_course_importer.rb to accept it.

Example fix

// before
importer.add_abstract_course('C101', 'CS101', 'Intro CS', 'inactive')
// after
importer.add_abstract_course('C101', 'CS101', 'Intro CS', 'active')
Defensive patterns

Strategy: validation

Validate before calling

def valid_sis_status?(s)
  %w[active deleted].any? { |ok| s.to_s.strip.downcase.start_with?(ok) }
end
raise ArgumentError, "bad status" unless valid_sis_status?(status)

Try / catch

begin
  importer.add_abstract_course(id, short, long, status)
rescue SIS::BaseImporter::ImportError => e
  logger.warn("skipping abstract course #{id}: #{e.message}")
end

Prevention

When it happens

Trigger: Calling AbstractCourseImporter::Importer#add_abstract_course with a status value that is nil, blank, misspelled (e.g. 'actve', 'deactivated'), or starts with other text (e.g. ' completed', 'inactive'). Note the regex only anchors the start, so 'deleted_permanently' passes but 'unpublished' fails.

Common situations: SIS CSV export scripts emitting non-Canvas status enums; whitespace/BOM prefixing the status cell; locale-translated status values; upstream systems using 'pending' or 'inactive' states.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at lib/sis/abstract_course_importer.rb:52

    end

    class Work
      attr_accessor :success_count, :abstract_courses_to_update_sis_batch_id, :roll_back_data

      def initialize(batch, root_account, logger)
        @batch = batch
        @root_account = root_account
        @abstract_courses_to_update_sis_batch_id = []
        @roll_back_data = []
        @logger = logger
        @success_count = 0
      end

      def add_abstract_course(abstract_course_id, short_name, long_name, status, term_id = nil, account_id = nil, fallback_account_id = nil)
        raise ImportError, "No abstract_course_id given for an abstract course" if abstract_course_id.blank?
        raise ImportError, "No short_name given for abstract course #{abstract_course_id}" if short_name.blank?
        raise ImportError, "No long_name given for abstract course #{abstract_course_id}" if long_name.blank?
        raise ImportError, "Improper status \"#{status}\" for abstract course #{abstract_course_id}" unless /\Aactive|\Adeleted/i.match?(status)
        return if @batch.skip_deletes? && status =~ /deleted/i

        course = AbstractCourse.find_by(root_account_id: @root_account, sis_source_id: abstract_course_id)
        course ||= AbstractCourse.new
        unless course.stuck_sis_fields.include?(:enrollment_term_id)
          course.enrollment_term = @root_account.enrollment_terms.find_by(sis_source_id: term_id) || @root_account.default_enrollment_term
        end
        course.root_account = @root_account

        account = nil
        account = @root_account.all_accounts.find_by(sis_source_id: account_id) if account_id.present?
        account ||= @root_account.all_accounts.find_by(sis_source_id: fallback_account_id) if fallback_account_id.present?
        course.account = account if account
        course.account ||= @root_account

        # only update the name/short_name on new records, and ones that haven't been changed
        # since the last sis import
        course.name = long_name if long_name.present? && (course.new_record? || !course.stuck_sis_fields.include?(:name))

View on GitHub (pinned to 1c9f0bb801)