{"record":{"id":"7c33f41b37f97395","repo":"instructure/canvas-lms","slug":"improper-status-status-for-a-is-tags-differentiation-tag","errorCode":null,"errorMessage":"Improper status \"#{status}\" for a #{is_tags ? \"differentiation tag\" : \"group\"} user","messagePattern":"Improper status \"#(.+?)\" for a #(.+?) user","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/group_membership_importer.rb","lineNumber":48,"sourceCode":"\n    class Work\n      attr_accessor :success_count, :roll_back_data\n\n      def initialize(batch, root_account, logger)\n        @batch = batch\n        @root_account = root_account\n        @logger = logger\n        @success_count = 0\n        @groups_cache = {}\n        @roll_back_data = []\n      end\n\n      def add_group_membership(user_id, group_id, status, is_tags: false)\n        user_id = user_id.to_s\n        group_id = group_id.to_s\n        raise ImportError, \"No #{is_tags ? \"tag_id\" : \"group_id\"} given for a #{is_tags ? \"differentiation tag\" : \"group\"} user\" if group_id.blank?\n        raise ImportError, \"No user_id given for a #{is_tags ? \"differentiation tag\" : \"group\"} user\" if user_id.blank?\n        raise ImportError, \"Improper status \\\"#{status}\\\" for a #{is_tags ? \"differentiation tag\" : \"group\"} user\" unless /\\A(accepted|deleted)/i.match?(status)\n        return if @batch.skip_deletes? && status =~ /deleted/i\n\n        pseudo = @root_account.pseudonyms.find_by(sis_user_id: user_id)\n        user = pseudo&.user\n\n        group = @groups_cache[group_id]\n        scope = is_tags ? @root_account.all_differentiation_tags : @root_account.all_groups\n        group ||= scope.where(sis_source_id: group_id).preload(:context).take\n        @groups_cache[group.sis_source_id] = group if group\n\n        raise ImportError, \"User #{user_id} didn't exist for #{is_tags ? \"differentiation tag\" : \"group\"} user\" unless user\n        raise ImportError, \"#{is_tags ? \"Differentiation tag\" : \"Group\"} #{group_id} didn't exist for #{is_tags ? \"differentiation tag\" : \"group\"} user\" unless group\n\n        if group.context.is_a?(Course) && !group.context.all_real_users.where(id: user.id).exists?\n          raise ImportError, \"User #{user_id} doesn't have an enrollment in the course of #{is_tags ? \"differentiation tag\" : \"group\"} #{group_id}.\"\n        end\n\n        if group && is_tags","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/group_membership_importer.rb#L30-L66","documentation":"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.","triggerScenarios":"CSV row whose status column contains values like 'active', 'accept', 'invited', 'completed', or a typo such as 'accepeted'; status nil also fails the regex.","commonSituations":"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.","solutions":["Use only 'accepted' or 'deleted' (case-insensitive) in the status column","Map the source system's status vocabulary to Canvas's accepted/deleted before import","Trim whitespace/casing if the value is semantically correct, e.g. 'Accepted' is fine but ' accepted\\r' should be stripped at export time","Validate status values in a pre-import lint step"],"exampleFix":"# before\nu_1,g_456,active\n# after\nu_1,g_456,accepted","handlingStrategy":"validation","validationCode":"STATUS_MAP = {\"active\" => \"accepted\", \"removed\" => \"deleted\"}\nstatus = STATUS_MAP.fetch(raw_status.to_s.strip.downcase, raw_status)\nraise 'invalid status' unless %w[accepted deleted].include?(status.downcase)","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_group_membership(uid, gid, status)\nrescue SIS::GroupImporter::ImportError => e\n  raise unless e.message.start_with?('Improper status')\n  Rails.logger.error(\"Bad status value: #{status.inspect}\")\nend","preventionTips":["Whitelist accepted/deleted in the export mapping","Translate foreign status vocabularies (active/removed) before import","Normalize casing and strip whitespace from status cells"],"tags":["sis-import","groups","invalid-enum","csv"],"backgroundTag":"invalid-enum-value","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"}