instructure/canvas-lms · error · ImportError
No long_name given for course #
Error message
No long_name given for course #{course_id} What it means
SisCourseImporter#add_course raises ImportError when long_name is blank AND abstract_course_id is also blank. The course display name (long_name) is required for any course that is not linked to an abstract course, since it is what users see in the UI.
Solutions
- Populate the long_name column (full course display name) in the courses.csv row
- Supply abstract_course_id instead so the course inherits identity from an existing abstract course
- Add pre-import validation requiring long_name (or abstract_course_id) on every course row
- Check the upstream export for fields being dropped or truncated to empty strings
Example fix
// before "course-101",term-1,account-1,,active,,,,,,"CS101","" // after "course-101",term-1,account-1,,active,,,,,,"CS101","Intro to Computer Science"
Defensive patterns
Strategy: validation
Validate before calling
if row['long_name'].to_s.strip.empty? && row['abstract_course_id'].to_s.strip.empty?
raise ArgumentError, "course #{row['course_id']} needs long_name or abstract_course_id"
end Type guard
def has_display_name?(row) = !row['long_name'].to_s.strip.empty? || !row['abstract_course_id'].to_s.strip.empty?
Try / catch
begin
importer.add_course(...)
rescue SisImport::ImportError => e
raise unless e.message.start_with?('No long_name given')
log.warn("course row missing long_name: #{e.message}")
end Prevention
- Make long_name a required column in your export pipeline
- Check exports for truncated/empty display names after transformations
- Validate the CSV against a schema before import
- Prefer failing loudly upstream rather than mid-batch
When it happens
Trigger: add_course called with long_name=nil/"" while abstract_course_id is also blank — a courses.csv row missing both the long_name column and abstract_course_id.
Common situations: Minimal CSV templates that only list ids and short codes; data exports that truncate names; bulk updates supplying only short_name; misunderstanding that short_name alone is enough to create a course.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- No short_name given for course #
- Improper status "# " for course #
- Invalid course_format "#
- Invalid grade_passback_setting "#
- No course_id given for a course
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/c5c0a04d7197c657.
Report an issue: GitHub.
Appendix: source
Thrown at lib/sis/course_importer.rb:68
def initialize(batch, root_account, logger, a1, a2, m, batch_user, blueprint_associations)
@batch = batch
@batch_user = batch_user
@root_account = root_account
@courses_to_update_sis_batch_id = a1
@course_ids_to_update_associations = a2
@roll_back_data = []
@blueprint_associations = blueprint_associations
@messages = m
@logger = logger
@success_count = 0
end
def add_course(course_id, term_id, account_id, fallback_account_id, status, start_date, end_date, abstract_course_id, short_name, long_name, integration_id, course_format, blueprint_course_id, grade_passback_setting, homeroom_course, friendly_name)
state_changes = []
raise ImportError, "No course_id given for a course" if course_id.blank?
raise ImportError, "No short_name given for course #{course_id}" if short_name.blank? && abstract_course_id.blank?
raise ImportError, "No long_name given for course #{course_id}" if long_name.blank? && abstract_course_id.blank?
raise ImportError, "Improper status \"#{status}\" for course #{course_id}" unless /\A(active|deleted|completed|unpublished|published)/i.match?(status)
raise ImportError, "Invalid course_format \"#{course_format}\" for course #{course_id}" unless course_format.blank? || course_format =~ /\A(online|on_campus|blended|not_set)/i
valid_grade_passback_settings = %w[nightly_sync disabled not_set]
raise ImportError, "Invalid grade_passback_setting \"#{grade_passback_setting}\" for course #{course_id}" unless grade_passback_setting.blank? || valid_grade_passback_settings.include?(grade_passback_setting.downcase.strip)
return if @batch.skip_deletes? && status =~ /deleted/i
Course.unique_constraint_retry do
course = @root_account.all_courses.find_by(sis_source_id: course_id)
if course.nil?
course = Course.new
state_changes << :created
else
state_changes << :updated
end
course.saved_by = :sis_import
course_enrollment_term_id_stuck = course.stuck_sis_fields.include?(:enrollment_term_id)
if !course_enrollment_term_id_stuck && term_idView on GitHub (pinned to 1c9f0bb801)