{"record":{"id":"9dabefd2bf6ebbef","repo":"instructure/canvas-lms","slug":"no-login-id-given-for-user-user-user-id","errorCode":null,"errorMessage":"No login_id given for user #{user.user_id}","messagePattern":"No login_id given for user #(.+?)","errorType":"validation","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/user_importer.rb","lineNumber":76,"sourceCode":"        @root_account = root_account\n        @logger = logger\n        @batched_users = []\n        @messages = messages\n        @success_count = 0\n\n        @roll_back_data = []\n        @users_to_set_sis_batch_ids = []\n        @pseudos_to_set_sis_batch_ids = []\n        @users_to_add_account_associations = []\n        @users_to_update_account_associations = []\n        @users_to_sync = Set.new\n        @authentication_providers = {}\n      end\n\n      # Pass a single instance of SIS::Models::User\n      def add_user(user, login_only: false)\n        raise ImportError, \"No user_id given for a user\" if user.user_id.blank?\n        raise ImportError, \"No login_id given for user #{user.user_id}\" if user.login_id.blank?\n        raise ImportError, \"No status given for user #{user.user_id}\" if user.status.blank?\n        raise ImportError, \"Improper status for user #{user.user_id}\" unless user.status.match?(/\\A(active|suspended|deleted)/i)\n        return if @batch.skip_deletes? && user.status.match?(/deleted/i)\n\n        if login_only && user.existing_user_id.blank? && user.existing_integration_id.blank? && user.existing_canvas_user_id.blank?\n          raise ImportError, I18n.t(\"No existing user provided for login with SIS ID %{user_id}\", user_id: user.user_id)\n        end\n\n        @batched_users << user\n        process_batch(login_only:) if @batched_users.size >= BATCH_SIZE\n      end\n\n      def any_left_to_process?\n        !@batched_users.empty?\n      end\n\n      def infer_user_name(user_row, prior_name = nil)\n        if user_row.full_name.present?","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/user_importer.rb#L58-L94","documentation":"add_user requires a non-blank login_id for every user being imported; the login is the credential users sign in with and is key to matching existing logins. After user_id passes, a blank login_id raises ImportError naming the offending user_id so the row can be located in the source file.","triggerScenarios":"add_user(user) where user.login_id is nil/empty — typically a CSV row missing the login_id (email) column, or a Models::User constructed without one; also hit when login_only: true imports only carry an existing_* id but still must supply a login.","commonSituations":"SIS exports where the email/login column is blank for some users; scripts that populate only user_id and status; column-rename in the source system after an upgrade.","solutions":["Populate login_id (usually the institutional email) on every user record before add_user","Pre-filter rows with blank login_id and report them as source-data errors","Check that your CSV/XML parser maps the login/email column to login_id (not a differently named field)","Use add_user_to_login or a login-only path only when a login genuinely exists"],"exampleFix":"// before\nimporter.add_user(Sis::Models::User.new(user_id: row['user_id'], status: row['status']))\n// after\nimporter.add_user(Sis::Models::User.new(user_id: row['user_id'], login_id: row['login_id'] || row['email'], status: row['status']))","handlingStrategy":"validation","validationCode":"next unless user.login_id.present?\nimporter.add_user(user)","typeGuard":"def has_login?(u)\n  u.is_a?(Sis::Models::User) && u.login_id.present?\nend","tryCatchPattern":"begin\n  importer.add_user(user)\nrescue SisImports::ImportError => e\n  errors << { user_id: user.user_id, reason: e.message }\nend","preventionTips":["Fall back to email when login_id is blank, per your data policy","Reject bad rows at parse time and surface them in the import report","Assert login_id presence in tests with fixture rows lacking it"],"tags":["sis","import","login","validation"],"backgroundTag":"empty-required-field","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"}