{"record":{"id":"a1060b993c408111","repo":"instructure/canvas-lms","slug":"a-type-display-did-not-pass-validation-type-display-sis-id","errorCode":null,"errorMessage":"A #{type_display} did not pass validation (#{type_display}: #{sis_id}, error: #{category.errors.full_messages.join(\",\")})","messagePattern":"A #(.+?) did not pass validation \\(#(.+?): #(.+?), error: #(.+?)\\)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/group_category_importer.rb","lineNumber":109,"sourceCode":"      def apply_status(category, status)\n        case status\n        when /active/i\n          category.deleted_at = nil\n        when /deleted/i\n          category.deleted_at = Time.zone.now\n        end\n      end\n\n      def save_category(category, sis_id, type_display)\n        if category.save\n          data = build_data(category)\n          @roll_back_data << data if data\n          @success_count += 1\n          true\n        else\n          msg = \"A #{type_display} did not pass validation (#{type_display}: #{sis_id}, error: \"\n          msg += category.errors.full_messages.join(\",\") + \")\"\n          raise ImportError, msg\n        end\n      end\n\n      def add_group_category(sis_id, account_id, course_id, category_name, status)\n        return if invalid_category?(sis_id, category_name, status, \"group category\")\n\n        context = find_context(account_id, course_id, sis_id, \"group category\")\n        gc = @root_account.all_group_categories.find_by(sis_source_id: sis_id)\n\n        check_context_movement(gc, context, sis_id, \"group category\")\n\n        gc ||= context.group_categories.new\n        gc.name = category_name\n        gc.context = context\n        gc.root_account_id = @root_account.id\n        gc.sis_source_id = sis_id\n        gc.sis_batch_id = @batch.id\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/group_category_importer.rb#L91-L127","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (duplicate name in same course)\ngc-2,Math Groups,,COURSE-42,active  # 'Math Groups' already exists in COURSE-42\n// after\ngc-2,Math Groups B,,COURSE-42,active","handlingStrategy":"try-catch","validationCode":"existing = course.group_categories.where(name: category_name).exists?\nraise ArgumentError, \"category name '#{category_name}' already exists in course\" if existing","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_group_category(sis_id, acct_id, course_id, name, status)\nrescue SIS::GroupCategoryImporter::ImportError => e\n  if e.message =~ /did not pass validation/ then report(sis_id, e.message)\n  else raise end\nend","preventionTips":["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"],"tags":["sis","csv-import","activerecord","model-validation"],"backgroundTag":"schema-validation-failed","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"}