instructure/canvas-lms · error · ImportError

Improper status "# " for a # user

Error message

Improper status "#{status}" for a #{is_tags ? "differentiation tag" : "group"} user

What it means

add_group_membership only accepts a status of 'accepted' or 'deleted' (case-insensitive). Any other status string raises ImportError, indicating an invalid workflow-state value for the membership row.

Solutions

  1. Use only 'accepted' or 'deleted' (case-insensitive) in the status column
  2. Map the source system's status vocabulary to Canvas's accepted/deleted before import
  3. Trim whitespace/casing if the value is semantically correct, e.g. 'Accepted' is fine but ' accepted\r' should be stripped at export time
  4. Validate status values in a pre-import lint step

Example fix

# before
u_1,g_456,active
# after
u_1,g_456,accepted
Defensive patterns

Strategy: validation

Validate before calling

STATUS_MAP = {"active" => "accepted", "removed" => "deleted"}
status = STATUS_MAP.fetch(raw_status.to_s.strip.downcase, raw_status)
raise 'invalid status' unless %w[accepted deleted].include?(status.downcase)

Try / catch

begin
  importer.add_group_membership(uid, gid, status)
rescue SIS::GroupImporter::ImportError => e
  raise unless e.message.start_with?('Improper status')
  Rails.logger.error("Bad status value: #{status.inspect}")
end

Prevention

When it happens

Trigger: CSV row whose status column contains values like 'active', 'accept', 'invited', 'completed', or a typo such as 'accepeted'; status nil also fails the regex.

Common situations: Export from another LMS using different status vocabulary; manual CSV authoring errors; API caller passing a symbol or unexpected state instead of the two allowed strings.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at lib/sis/group_membership_importer.rb:48

    class Work
      attr_accessor :success_count, :roll_back_data

      def initialize(batch, root_account, logger)
        @batch = batch
        @root_account = root_account
        @logger = logger
        @success_count = 0
        @groups_cache = {}
        @roll_back_data = []
      end

      def add_group_membership(user_id, group_id, status, is_tags: false)
        user_id = user_id.to_s
        group_id = group_id.to_s
        raise ImportError, "No #{is_tags ? "tag_id" : "group_id"} given for a #{is_tags ? "differentiation tag" : "group"} user" if group_id.blank?
        raise ImportError, "No user_id given for a #{is_tags ? "differentiation tag" : "group"} user" if user_id.blank?
        raise ImportError, "Improper status \"#{status}\" for a #{is_tags ? "differentiation tag" : "group"} user" unless /\A(accepted|deleted)/i.match?(status)
        return if @batch.skip_deletes? && status =~ /deleted/i

        pseudo = @root_account.pseudonyms.find_by(sis_user_id: user_id)
        user = pseudo&.user

        group = @groups_cache[group_id]
        scope = is_tags ? @root_account.all_differentiation_tags : @root_account.all_groups
        group ||= scope.where(sis_source_id: group_id).preload(:context).take
        @groups_cache[group.sis_source_id] = group if group

        raise ImportError, "User #{user_id} didn't exist for #{is_tags ? "differentiation tag" : "group"} user" unless user
        raise ImportError, "#{is_tags ? "Differentiation tag" : "Group"} #{group_id} didn't exist for #{is_tags ? "differentiation tag" : "group"} user" unless group

        if group.context.is_a?(Course) && !group.context.all_real_users.where(id: user.id).exists?
          raise ImportError, "User #{user_id} doesn't have an enrollment in the course of #{is_tags ? "differentiation tag" : "group"} #{group_id}."
        end

        if group && is_tags

View on GitHub (pinned to 1c9f0bb801)