{"record":{"id":"112afe3849fe8ed0","repo":"instructure/canvas-lms","slug":"no-enrollment-id-given","errorCode":null,"errorMessage":"No enrollment_id given","messagePattern":"No enrollment_id given","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/grade_publishing_results_importer.rb","lineNumber":40,"sourceCode":"  class GradePublishingResultsImporter < BaseImporter\n    def process\n      importer = Work.new(@batch, @root_account, @logger)\n      yield importer\n      importer.success_count\n    end\n\n    class Work\n      attr_accessor :success_count\n\n      def initialize(batch, root_account, logger)\n        @batch = batch\n        @root_account = root_account\n        @logger = logger\n        @success_count = 0\n      end\n\n      def add_grade_publishing_result(enrollment_id, grade_publishing_status, message = nil)\n        raise ImportError, \"No enrollment_id given\" if enrollment_id.blank?\n        raise ImportError, \"No grade_publishing_status given for enrollment #{enrollment_id}\" if grade_publishing_status.blank?\n        raise ImportError, \"Improper grade_publishing_status \\\"#{grade_publishing_status}\\\" for enrollment #{enrollment_id}\" unless %w[published error].include?(grade_publishing_status.downcase)\n\n        if Enrollment.where(id: enrollment_id, root_account_id: @root_account)\n                     .update_all(grade_publishing_status: grade_publishing_status.downcase,\n                                 grade_publishing_message: message.to_s,\n                                 updated_at: Time.now.utc) != 1\n          raise ImportError, \"Enrollment #{enrollment_id} doesn't exist\"\n        end\n\n        @success_count += 1\n      end\n    end\n  end\nend\n","sourceCodeStart":22,"sourceCodeEnd":56,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/grade_publishing_results_importer.rb#L22-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Populate enrollment_id in the input CSV for every row","Fix column ordering/mapping so the id is passed as the first argument","Guard the call: skip rows with blank ids before invoking the importer"],"exampleFix":"// before\nimporter.add_grade_publishing_result(row['enrollment_id'], row['status'])\n// after\nnext if row['enrollment_id'].blank?\nimporter.add_grade_publishing_result(row['enrollment_id'], row['status'])","handlingStrategy":"validation","validationCode":"next if enrollment_id.blank?\nimporter.add_grade_publishing_result(enrollment_id, status)","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_grade_publishing_result(id, status)\nrescue SIS::Base::ImportError => e\n  logger.warn(\"Skipping grade publishing result: #{e.message}\")\nend","preventionTips":["Reject blank id rows at CSV load time","Verify argument order when calling add_grade_publishing_result","Log skipped rows for later reconciliation"],"tags":["ruby","sis-import","grade-publishing","missing-identifier"],"backgroundTag":"missing-required-argument","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"}