{"record":{"id":"43a82ad7eabf5fcf","repo":"instructure/canvas-lms","slug":"invalid-or-unknown-user-id-user-id-for-admin","errorCode":null,"errorMessage":"Invalid or unknown user_id '#{user_id}' for admin","messagePattern":"Invalid or unknown user_id '#(.+?)' for admin","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/admin_importer.rb","lineNumber":79,"sourceCode":"\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)\n        raise ImportError, \"Invalid or unknown user_id '#{user_id}' for admin\" unless user\n\n        if state == \"deleted\" && user.id == @batch&.user_id && @account == @root_account\n          raise ImportError, \"Can't remove yourself user_id '#{user_id}'\"\n        end\n\n        create_or_find_admin(user, state)\n        user.clear_adminable_accounts_cache!\n        @success_count += 1\n      end\n\n      def create_or_find_admin(user, state)\n        case state\n        when \"active\"","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/admin_importer.rb#L61-L97","documentation":"First of two identical messages: raised when a `root_account` was supplied but root_account_from_id cannot resolve it, so the importer cannot scope the user lookup. The admin row's root account reference is invalid or unknown.","triggerScenarios":"process_admin called with root_account: set to an id/sis id that does not resolve to an account; multi-tenant imports referencing a root account that does not exist.","commonSituations":"Multi-tenant setups where CSVs were generated against a different root account; typo in root_account sis id; root account deleted or not yet imported.","solutions":["Verify the root_account identifier resolves to an existing root account and correct it.","Remove the root_account argument so the importer's default @root_account (batch root) is used.","Ensure the root account is created/imported before the admin import runs."],"exampleFix":"// before\nprocess_admin(user_id: 'u1', account_id: 'a1', role: 'AccountAdmin', status: 'active', root_account: 'missing-root')\n// after\nprocess_admin(user_id: 'u1', account_id: 'a1', role: 'AccountAdmin', status: 'active') # uses batch root account","handlingStrategy":"validation","validationCode":"ra = root_account_id && (Account.find_by(id: root_account_id) ||\n  Account.find_by(sis_source_id: root_account_id, root_account: true))\nraise ArgumentError, 'root_account not found' if root_account_id && !ra&.root_account?","typeGuard":null,"tryCatchPattern":"begin\n  importer.process_admin(user_id:, account_id:, role:, status:, root_account:)\nrescue SIS::ImportError => e\n  errors << { row: row_no, message: e.message }\nend","preventionTips":["Only pass root_account when targeting a non-default tenant; otherwise omit it.","Confirm root account sis ids exist before multi-tenant imports.","Keep a registry of valid root account identifiers for your tooling."],"tags":["sis-import","entity-not-found","multi-tenancy"],"backgroundTag":"record-not-found","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"}