instructure/canvas-lms · error · ImportError

No enrollment_id given

Error message

No enrollment_id given

What it means

GradePublishingResultsImporter.add_grade_publishing_result raises ImportError when the enrollment_id argument is blank. Without an enrollment id there is nothing to attach the grade publishing status to.

Solutions

  1. Populate enrollment_id in the input CSV for every row
  2. Fix column ordering/mapping so the id is passed as the first argument
  3. Guard the call: skip rows with blank ids before invoking the importer

Example fix

// before
importer.add_grade_publishing_result(row['enrollment_id'], row['status'])
// after
next if row['enrollment_id'].blank?
importer.add_grade_publishing_result(row['enrollment_id'], row['status'])
Defensive patterns

Strategy: validation

Validate before calling

next if enrollment_id.blank?
importer.add_grade_publishing_result(enrollment_id, status)

Try / catch

begin
  importer.add_grade_publishing_result(id, status)
rescue SIS::Base::ImportError => e
  logger.warn("Skipping grade publishing result: #{e.message}")
end

Prevention

When it happens

Trigger: Calling `importer.add_grade_publishing_result(nil_or_empty_id, status, msg)` — e.g. an empty enrollment_id column in the grade publishing results CSV, or passing nil programmatically.

Common situations: CSV with blank/missing enrollment_id column; export join dropped rows so the id column is empty; scripts passing the wrong variable (unset local) as the first argument.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at lib/sis/grade_publishing_results_importer.rb:40

  class GradePublishingResultsImporter < BaseImporter
    def process
      importer = Work.new(@batch, @root_account, @logger)
      yield importer
      importer.success_count
    end

    class Work
      attr_accessor :success_count

      def initialize(batch, root_account, logger)
        @batch = batch
        @root_account = root_account
        @logger = logger
        @success_count = 0
      end

      def add_grade_publishing_result(enrollment_id, grade_publishing_status, message = nil)
        raise ImportError, "No enrollment_id given" if enrollment_id.blank?
        raise ImportError, "No grade_publishing_status given for enrollment #{enrollment_id}" if grade_publishing_status.blank?
        raise ImportError, "Improper grade_publishing_status \"#{grade_publishing_status}\" for enrollment #{enrollment_id}" unless %w[published error].include?(grade_publishing_status.downcase)

        if Enrollment.where(id: enrollment_id, root_account_id: @root_account)
                     .update_all(grade_publishing_status: grade_publishing_status.downcase,
                                 grade_publishing_message: message.to_s,
                                 updated_at: Time.now.utc) != 1
          raise ImportError, "Enrollment #{enrollment_id} doesn't exist"
        end

        @success_count += 1
      end
    end
  end
end

View on GitHub (pinned to 1c9f0bb801)