{"record":{"id":"f040182c3e948d1b","repo":"instructure/canvas-lms","slug":"no-existing-user-provided-for-login-with-sis-id-user-id","errorCode":null,"errorMessage":"No existing user provided for login with SIS ID %{user_id}","messagePattern":"No existing user provided for login with SIS ID %(.+?)","errorType":"validation","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/user_importer.rb","lineNumber":82,"sourceCode":"        @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?\n          user_row.full_name\n        elsif user_row.first_name.present? || user_row.last_name.present?\n          [user_row.first_name, user_row.last_name].join(\" \")\n        elsif prior_name.present?\n          prior_name\n        elsif user_row.sortable_name.present?","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/user_importer.rb#L64-L100","documentation":"When add_user is called with login_only: true, the call is meant to attach/repair a login on an EXISTING Canvas user, so the record must identify that user via existing_user_id, existing_integration_id, or existing_canvas_user_id. If none is set, ImportError (I18n-translated) is raised because a login cannot be created for an unknown user.","triggerScenarios":"importer.add_user(user, login_only: true) where user has only user_id/login_id but existing_user_id, existing_integration_id, and existing_canvas_user_id are all blank.","commonSituations":"Re-running a user import in login-only mode against rows that were originally new-user rows; scripts that clear the existing_* match fields; a CSV that relies on SIS user_id matching but that path is only honored via existing_user_id in this mode.","solutions":["Set existing_user_id (SIS id of the existing user) or existing_canvas_user_id before calling with login_only: true","Resolve the matching user first (e.g. via Pseudonym/User lookup) and populate the existing_* field","Drop login_only: true and do a full user import if the row may create a new user","Use a non-login-only path for new users and reserve login_only for repairs"],"exampleFix":"// before\nimporter.add_user(user, login_only: true) # user.existing_user_id blank\n// after\nuser.existing_user_id = user.user_id # or canvas user id in existing_canvas_user_id\nimporter.add_user(user, login_only: true)","handlingStrategy":"validation","validationCode":"if login_only && user.existing_user_id.blank? && user.existing_integration_id.blank? && user.existing_canvas_user_id.blank?\n  raise ArgumentError, 'login_only import requires an existing user reference'\nend","typeGuard":"def resolvable_for_login_only?(u)\n  u.existing_user_id.present? || u.existing_integration_id.present? || u.existing_canvas_user_id.present?\nend","tryCatchPattern":"begin\n  importer.add_user(user, login_only: true)\nrescue SisImports::ImportError => e\n  Rails.logger.warn(\"cannot attach login: #{e.message}\")\nend","preventionTips":["Resolve existing users before login-only imports and populate existing_* fields","Only use login_only for known-existing users, not new rows","Log which match key (SIS vs canvas id) was used for traceability"],"tags":["sis","import","login","lookup"],"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"}