instructure/canvas-lms · error · ImportError
A # did not pass validation (# : # , error: # )
Error message
A #{type_display} did not pass validation (#{type_display}: #{sis_id}, error: #{category.errors.full_messages.join(",")}) What it means
save_category saves the built GroupCategory / DifferentiationTagCategory model; if ActiveRecord validation fails (category.errors), the importer raises ImportError with the model's full_messages so the SIS row author can correct the offending data.
Solutions
- Read the embedded error message — it lists the exact model validation failures.
- Rename the category in the CSV if it collides with an existing category in the same course.
- Shorten the name to fit the database column limit.
- Check the context resolution: if the sis_id unexpectedly maps to a different existing category, its stale attributes may be failing validation.
Example fix
// before (duplicate name in same course) gc-2,Math Groups,,COURSE-42,active # 'Math Groups' already exists in COURSE-42 // after gc-2,Math Groups B,,COURSE-42,active
Defensive patterns
Strategy: try-catch
Validate before calling
existing = course.group_categories.where(name: category_name).exists?
raise ArgumentError, "category name '#{category_name}' already exists in course" if existing Try / catch
begin importer.add_group_category(sis_id, acct_id, course_id, name, status) rescue SIS::GroupCategoryImporter::ImportError => e if e.message =~ /did not pass validation/ then report(sis_id, e.message) else raise end end
Prevention
- Pre-check name uniqueness within each course context before import
- Enforce DB column length limits on name fields in the export tool
- Parse the embedded ActiveRecord full_messages from the error to target fixes
When it happens
Trigger: add_group_category or add_differentiation_tag_set builds a category whose attributes fail model validations — e.g., duplicate category name within the same course context, name too long, or nil required attributes that slipped past row-level checks.
Common situations: Two rows in the same import (or an existing UI-created category) sharing a name in the same course; CSV names exceeding the column length limit; special/whitespace-only names failing presence or format validations.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- account.errors.first.message
- Account with id "# " didn't exist for # #
- Cannot move # # because it has # in it.
- Cannot restore sub_account with ID: #
- Course with id "# " didn't exist for # #
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/a1060b993c408111.
Report an issue: GitHub.
Appendix: source
Thrown at lib/sis/group_category_importer.rb:109
def apply_status(category, status)
case status
when /active/i
category.deleted_at = nil
when /deleted/i
category.deleted_at = Time.zone.now
end
end
def save_category(category, sis_id, type_display)
if category.save
data = build_data(category)
@roll_back_data << data if data
@success_count += 1
true
else
msg = "A #{type_display} did not pass validation (#{type_display}: #{sis_id}, error: "
msg += category.errors.full_messages.join(",") + ")"
raise ImportError, msg
end
end
def add_group_category(sis_id, account_id, course_id, category_name, status)
return if invalid_category?(sis_id, category_name, status, "group category")
context = find_context(account_id, course_id, sis_id, "group category")
gc = @root_account.all_group_categories.find_by(sis_source_id: sis_id)
check_context_movement(gc, context, sis_id, "group category")
gc ||= context.group_categories.new
gc.name = category_name
gc.context = context
gc.root_account_id = @root_account.id
gc.sis_source_id = sis_id
gc.sis_batch_id = @batch.id
View on GitHub (pinned to 1c9f0bb801)