{"record":{"id":"f6edfd3247c23bd4","repo":"instructure/canvas-lms","slug":"a-is-tags-differentiation-tag-group-user-did-not-pass","errorCode":null,"errorMessage":"A #{is_tags ? \"differentiation tag\" : \"group\"} user did not pass validation (user: #{user_id}, #{is_tags ? \"differentiation tag\" : \"group\"}: #{group_id}, error: #{group_membership.errors.full_messages.join(\", \")})","messagePattern":"A #(.+?) user did not pass validation \\(user: #(.+?), #(.+?): #(.+?), error: #(.+?)\\)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/group_membership_importer.rb","lineNumber":92,"sourceCode":"\n        group_membership.sis_batch_id = @batch.id\n\n        case status\n        when /accepted/i\n          group_membership.workflow_state = \"accepted\"\n        when /deleted/i\n          group_membership.workflow_state = \"deleted\"\n        end\n\n        if group_membership.valid?\n          group_membership.save\n          data = SisBatchRollBackData.build_data(sis_batch: @batch, context: group_membership)\n          @roll_back_data << data if data\n        else\n          msg = \"A #{is_tags ? \"differentiation tag\" : \"group\"} user did not pass validation \"\n          msg += \"(\" + \"user: #{user_id}, #{is_tags ? \"differentiation tag\" : \"group\"}: #{group_id}, error: \"\n          msg += group_membership.errors.full_messages.join(\", \") + \")\"\n          raise ImportError, msg\n        end\n        @success_count += 1\n      end\n    end\n  end\nend\n","sourceCodeStart":74,"sourceCodeEnd":99,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/group_membership_importer.rb#L74-L99","documentation":"If the GroupMembership record fails ActiveRecord validation on save, the importer raises an ImportError that embeds the user id, group id, and the model's full error messages, so the SIS row author knows exactly why the membership was rejected.","triggerScenarios":"add_group_membership builds/saves a group_membership whose validations fail — e.g. duplicate active membership in a limited-membership group, invalid user/group association, model-level constraint violations surfaced by errors.full_messages.","commonSituations":"Group at membership capacity; attempting to add the same user twice within one batch; user/group in inconsistent states (deleted group); concurrent imports conflicting on the same membership.","solutions":["Read the embedded error message (after 'error: ') to see the exact validation failure and fix the data accordingly","Check the group's member limits and remove duplicate membership rows in the batch","Ensure the group and user are both active and compatible (same course/account context)","Re-run the import after correcting the offending row"],"exampleFix":"# before\nduplicate rows: u_100,g_456,accepted twice in one batch\n# after\nsingle membership row per user/group pair in the batch","handlingStrategy":"try-catch","validationCode":"gm = group.group_memberships.build(user: user)\nunless gm.valid?\n  raise \"would fail validation: #{gm.errors.full_messages.join(', ')}\"\nend","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_group_membership(uid, gid, status)\nrescue SIS::GroupImporter::ImportError => e\n  raise unless e.message.include?('did not pass validation')\n  Rails.logger.error(\"Membership rejected: #{e.message}\")\n  # inspect error detail after 'error: ' and fix the offending row\nend","preventionTips":["Deduplicate user/group pairs within a batch before import","Check group member limits before bulk additions","Ensure both user and group are active and share a valid context","Dry-run problematic rows in console with GroupMembership#valid? before batch import"],"tags":["sis-import","groups","validation","activerecord"],"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"}