{"record":{"id":"266bb99dd5d0634d","repo":"instructure/canvas-lms","slug":"no-status-given-for-admin","errorCode":null,"errorMessage":"No status given for admin","messagePattern":"No status given for admin","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/admin_importer.rb","lineNumber":64,"sourceCode":"                    :roll_back_data,\n                    :account_users_to_update_associations,\n                    :account_users_to_set_batch_id\n\n      def initialize(batch, root_account, logger)\n        @batch = batch\n        @root_account = root_account\n        @account = root_account\n        @logger = logger\n        @success_count = 0\n        @roll_back_data = []\n        @account_users_to_update_associations = Set.new\n        @account_users_to_set_batch_id = Set.new\n        @account_roles_by_account_id = {}\n      end\n\n      def process_admin(user_id: nil, account_id: nil, role_id: nil, role: nil, status: nil, root_account: nil)\n        raise ImportError, \"No user_id given for admin\" if user_id.blank?\n        raise ImportError, \"No status given for admin\" if status.blank?\n        raise ImportError, \"No role_id or role given for admin\" if role.blank? && role_id.blank?\n\n        state = status.downcase.strip\n        raise ImportError, \"Invalid status #{status} for admin\" unless %w[active deleted].include? state\n        return if @batch.skip_deletes? && state == \"deleted\"\n\n        get_account(account_id)\n        raise ImportError, \"Invalid account_id given for admin\" unless @account\n\n        get_role(role_id, role)\n        raise ImportError, \"Invalid role '#{role}' for admin\" if role.present? && !@role\n        raise ImportError, \"Invalid role_id '#{role_id}' for admin\" if role_id.present? && !@role\n\n        the_root_account = root_account_from_id(root_account) if root_account\n        raise ImportError, \"Invalid or unknown user_id '#{user_id}' for admin\" if root_account && !the_root_account\n\n        the_root_account ||= @root_account\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/admin_importer.rb#L46-L82","documentation":"SIS CSV admin import validation in SIS::AdminImporter#process_admin. It raises ImportError when a row defines an admin (user/account/role) but the `status` column is blank. The importer needs an explicit state to know whether to activate or delete the admin membership.","triggerScenarios":"Calling process_admin(user_id:, account_id:, role_id:/role:, root_account:) without passing status, or an admin CSV row whose `status` column is empty.","commonSituations":"Hand-edited SIS admin CSVs missing the status column; CSV parsers dropping empty columns; custom scripts calling the importer API directly and forgetting the keyword argument; templates that omit status for header-only files.","solutions":["Add a `status` value of `active` or `deleted` to the admin row / pass status: to process_admin.","Validate the CSV before import (check required headers user_id, account_id, role, status and non-blank status values).","If the record is intended as a no-op, remove the row entirely rather than leaving status blank."],"exampleFix":"// before\nprocess_admin(user_id: 'u1', account_id: 'a1', role: 'AccountAdmin')\n// after\nprocess_admin(user_id: 'u1', account_id: 'a1', role: 'AccountAdmin', status: 'active')","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'status is required for admin' if status.blank?\nunless %w[active deleted].include?(status.to_s.downcase.strip)\n  raise ArgumentError, \"status must be 'active' or 'deleted'\"\nend","typeGuard":null,"tryCatchPattern":"begin\n  importer.process_admin(user_id:, account_id:, role:, status:)\nrescue SIS::ImportError => e\n  errors << { row: row_no, message: e.message }\nend","preventionTips":["Validate CSV headers and required non-blank columns (user_id, account_id, role/role_id, status) before upload.","Keep a canonical admin CSV template with all required columns.","Add integration tests for admin import rows with missing fields."],"tags":["sis-import","csv-validation","missing-field"],"backgroundTag":"missing-required-argument","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"}