{"record":{"id":"4a73df0f3f297b53","repo":"instructure/canvas-lms","slug":"improper-status-enrollment-status-for-an-enrollment","errorCode":null,"errorMessage":"Improper status \"#{enrollment.status}\" for an enrollment","messagePattern":"Improper status \"#(.+?)\" for an enrollment","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/enrollment_importer.rb","lineNumber":135,"sourceCode":"        @courses_to_touch_ids = Set.new\n        @courses_to_recache_due_dates = {}\n        @enrollments_to_add_to_favorites = []\n        @enrollments_to_update_sis_batch_ids = []\n        @roll_back_data = []\n        @enrollments_to_delete = []\n        @account_chain_cache = {}\n        @course = @section = nil\n        @course_roles_by_account_id = {}\n\n        @enrollment_batch = []\n        @success_count = 0\n      end\n\n      # Pass a single instance of SIS::Models::Enrollment\n      def add_enrollment(enrollment)\n        raise ImportError, \"No course_id or section_id given for an enrollment\" unless enrollment.valid_context?\n        raise ImportError, \"No user_id given for an enrollment\" unless enrollment.valid_user?\n        raise ImportError, \"Improper status \\\"#{enrollment.status}\\\" for an enrollment\" unless enrollment.valid_status?\n        return if @batch.skip_deletes? && enrollment.status =~ /deleted/i\n\n        @enrollment_batch << enrollment\n        process_batch if @enrollment_batch.size >= BATCH_SIZE\n      end\n\n      def any_left_to_process?\n        !@enrollment_batch.empty?\n      end\n\n      def process_batch\n        return unless any_left_to_process?\n\n        enrollment_info = nil\n        until @enrollment_batch.empty?\n          enrollment_info = @enrollment_batch.shift\n\n          @last_section = @section if @section","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/enrollment_importer.rb#L117-L153","documentation":"EnrollmentImporter.add_enrollment raises ImportError when `enrollment.valid_status?` is false, i.e. the enrollment status is not one of the accepted values (active, deleted, completed, inactive and variants, case-insensitive). The interpolated status is included in the message to show the offending value.","triggerScenarios":"Calling `add_enrollment(enrollment)` with a status like 'enrolled', 'ACTIVE ', 'drop', or a typo such as 'actve'; CSV rows with unexpected values in the status/enrollment_state column.","commonSituations":"Exports from other SIS/LMS systems using their own state vocabularies ('enrolled', 'pending', 'withdrawn'); trailing whitespace or casing assumptions; header mapped to the wrong column (e.g. role instead of status).","solutions":["Map source statuses to Canvas-accepted values: active, deleted, completed, inactive (case-insensitive)","Trim/normalize the status string before constructing the Enrollment","Add a preprocessing step that translates foreign status vocabularies","Check the CSV header mapping so the status column is parsed correctly"],"exampleFix":"// before\nSIS::Models::Enrollment.new(course_id: 'c1', user_id: 'u1', status: 'enrolled')\n// after\nSIS::Models::Enrollment.new(course_id: 'c1', user_id: 'u1', status: 'active')","handlingStrategy":"validation","validationCode":"ALLOWED = %w[active deleted completed inactive]\nraise 'bad status' unless ALLOWED.include?(enrollment.status.to_s.strip.downcase)","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_enrollment(enrollment)\nrescue SIS::Base::ImportError => e\n  logger.warn(\"Skipping enrollment: #{e.message}\")\nend","preventionTips":["Normalize status with strip/downcase before constructing the model","Map foreign status vocabularies to Canvas values in the export step","Document accepted statuses for whoever produces the CSV"],"tags":["ruby","sis-import","enrollment","invalid-enum"],"backgroundTag":"invalid-enum-value","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"}