{"record":{"id":"230fc76425d60511","repo":"instructure/canvas-lms","slug":"improper-status-status-for-account-account-id-skipping","errorCode":null,"errorMessage":"Improper status \"#{status}\" for account #{account_id}, skipping","messagePattern":"Improper status \"#(.+?)\" for account #(.+?), skipping","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/account_importer.rb","lineNumber":69,"sourceCode":"      def add_account(account_id, parent_account_id, status, name, integration_id)\n        raise ImportError, \"No account_id given for an account\" if account_id.blank?\n        return if @batch.skip_deletes? && status =~ /deleted/i\n\n        parent = nil\n        unless parent_account_id.blank?\n          parent = @accounts_cache[parent_account_id]\n          parent ||= @root_account.all_accounts.find_by(sis_source_id: parent_account_id)\n          raise ImportError, \"Parent account didn't exist for #{account_id}\" unless parent\n          raise ImportError, \"Cannot restore sub_account with ID: #{account_id} because parent_account with ID: #{parent_account_id} has been deleted.\" if parent.workflow_state == \"deleted\"\n\n          @accounts_cache[parent.sis_source_id] = parent\n        end\n\n        account = @accounts_cache[account_id]\n        account ||= @root_account.all_accounts.find_by(sis_source_id: account_id)\n        if account.nil?\n          raise ImportError, \"No name given for account #{account_id}, skipping\" if name.blank?\n          raise ImportError, \"Improper status \\\"#{status}\\\" for account #{account_id}, skipping\" unless /\\A(active|deleted)/i.match?(status)\n        end\n\n        account ||= @root_account.sub_accounts.new\n\n        account.root_account = @root_account\n        if account.new_record? || !account.stuck_sis_fields.include?(:parent_account_id) || Account.sis_stickiness_options[:add_sis_stickiness]\n          account.parent_account = parent || @root_account\n        end\n\n        # only update the name on new records, and ones that haven't been changed since the last sis import\n        account.name = name if name.present? && (account.new_record? || !account.stuck_sis_fields.include?(:name))\n\n        account.integration_id = integration_id if integration_id.present?\n        account.sis_source_id = account_id\n\n        if status.present?\n          case status\n          when /active/i","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/account_importer.rb#L51-L87","documentation":"For a new account (no existing record found by sis_source_id), the status must match /\\A(active|deleted)/i; otherwise ImportError is raised. Only the two workflow states Canvas supports for accounts are accepted when creating a sub-account from SIS.","triggerScenarios":"add_account with a status like 'suspended', 'inactive', 'pending', or blank for an account_id that doesn't yet exist under the root account.","commonSituations":"Source systems exporting richer status enums than Canvas supports; translated status strings; blank status cells in accounts.csv for new accounts.","solutions":["Set the status to 'active' or 'deleted' for new accounts in the SIS CSV.","Map non-Canvas statuses to active/deleted before import.","If the account exists already, note status validation is skipped (any status string just results in no workflow change), so aligning the value still matters for consistency."],"exampleFix":"// before\nadd_account('sub3', 'parent1', 'inactive', 'Sub', nil)\n// after\nadd_account('sub3', 'parent1', 'active', 'Sub', nil)","handlingStrategy":"validation","validationCode":"raise ArgumentError, \"status must be active|deleted\" unless %w[active deleted].include?(status.to_s.strip.downcase)","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_account(id, parent_id, status, name, integration_id)\nrescue SIS::BaseImporter::ImportError => e\n  logger.warn(\"#{e.message}\")\nend","preventionTips":["Normalize all statuses through a single mapper to active/deleted","Reject rows with unrecognized statuses at CSV parse time","Keep an enum test fixture per source system"],"tags":["sis","validation","enum"],"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"}