{"record":{"id":"449fd72aea591de9","repo":"instructure/canvas-lms","slug":"no-role-id-or-role-given-for-admin","errorCode":null,"errorMessage":"No role_id or role given for admin","messagePattern":"No role_id or role given for admin","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/admin_importer.rb","lineNumber":65,"sourceCode":"                    :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\n        user = get_user(user_id, the_root_account)","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/admin_importer.rb#L47-L83","documentation":"Raised by SIS::AdminImporter#process_admin when neither `role_id` nor `role` is provided for an admin row. The importer must resolve a concrete role to create the account-user membership, so at least one role identifier is mandatory.","triggerScenarios":"process_admin(user_id:, account_id:, status:) called with both role: and role_id: nil/blank; CSV row with empty `role` and `role_id` columns.","commonSituations":"CSV template missing the role column; exporters that only emit role_id or only role while the importer input has neither; scripts assuming a default admin role is applied automatically.","solutions":["Set the `role` column to a known role name (e.g. AccountAdmin) or provide `role_id` for the row.","Look up the role id in the target account (Account.roles / role_overrides) and pass role_id: explicitly.","Add CSV pre-validation requiring exactly one of role or role_id per admin row."],"exampleFix":"// before\nprocess_admin(user_id: 'u1', account_id: 'a1', status: 'active')\n// after\nprocess_admin(user_id: 'u1', account_id: 'a1', status: 'active', role: 'AccountAdmin')","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'provide role or role_id for admin' if role.blank? && role_id.blank?","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":["Always include the role column in admin CSV exports.","Validate that exactly one of role / role_id is present per row before import.","Document the default AccountAdmin role name in your SIS tooling."],"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"}