instructure/canvas-lms · error · ImportError

A # user did not pass validation (user: # , # : # , error…

Error message

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(", ")})

What it means

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.

Solutions

  1. Read the embedded error message (after 'error: ') to see the exact validation failure and fix the data accordingly
  2. Check the group's member limits and remove duplicate membership rows in the batch
  3. Ensure the group and user are both active and compatible (same course/account context)
  4. Re-run the import after correcting the offending row

Example fix

# before
duplicate rows: u_100,g_456,accepted twice in one batch
# after
single membership row per user/group pair in the batch
Defensive patterns

Strategy: try-catch

Validate before calling

gm = group.group_memberships.build(user: user)
unless gm.valid?
  raise "would fail validation: #{gm.errors.full_messages.join(', ')}"
end

Try / catch

begin
  importer.add_group_membership(uid, gid, status)
rescue SIS::GroupImporter::ImportError => e
  raise unless e.message.include?('did not pass validation')
  Rails.logger.error("Membership rejected: #{e.message}")
  # inspect error detail after 'error: ' and fix the offending row
end

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/f6edfd3247c23bd4. Report an issue: GitHub.

Appendix: source

Thrown at lib/sis/group_membership_importer.rb:92

        group_membership.sis_batch_id = @batch.id

        case status
        when /accepted/i
          group_membership.workflow_state = "accepted"
        when /deleted/i
          group_membership.workflow_state = "deleted"
        end

        if group_membership.valid?
          group_membership.save
          data = SisBatchRollBackData.build_data(sis_batch: @batch, context: group_membership)
          @roll_back_data << data if data
        else
          msg = "A #{is_tags ? "differentiation tag" : "group"} user did not pass validation "
          msg += "(" + "user: #{user_id}, #{is_tags ? "differentiation tag" : "group"}: #{group_id}, error: "
          msg += group_membership.errors.full_messages.join(", ") + ")"
          raise ImportError, msg
        end
        @success_count += 1
      end
    end
  end
end

View on GitHub (pinned to 1c9f0bb801)