{"record":{"id":"e5e08e62f3309178","repo":"atuinsh/atuin","slug":"unexpected-two-factor-requirement-during-registrat","errorCode":null,"errorMessage":"unexpected two-factor requirement during registration","messagePattern":"unexpected two-factor requirement during registration","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin/src/command/client/account/register.rs","lineNumber":93,"sourceCode":"                        let is_hub_token =\n                            auth_type.as_deref() == Some(\"hub\") || session.starts_with(\"atapi_\");\n\n                        if is_hub_token {\n                            meta.save_hub_session(&session).await?;\n                        } else {\n                            meta.save_session(&session).await?;\n                            println!(\n                                \"\\nNote: Your account has not been fully migrated to Atuin Hub.\"\n                            );\n                            println!(\n                                \"Sync will continue to work, but you can visit hub.atuin.sh to \\\n                                 create a new Hub account and link it to your existing CLI \\\n                                 account.\"\n                            );\n                        }\n                    }\n                    AuthResponse::TwoFactorRequired => {\n                        bail!(\"unexpected two-factor requirement during registration\");\n                    }\n                }\n\n                let _key = paseto_v4::Key::try_load_or_generate(&settings.key_path)?;\n\n                println!(\n                    \"Registration successful! Please make a note of your key (run 'atuin key') \\\n                     and keep it safe.\"\n                );\n                println!(\n                    \"You will need it to log in on other devices, and we cannot help recover it \\\n                     if you lose it.\"\n                );\n            } else {\n                // Interactive registration: delegate to the browser OAuth flow.\n                // Registration on Hub happens on the website; the CLI just needs\n                // to authenticate afterwards.\n                super::login::Cmd {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/atuinsh/atuin/blob/c0c717ab04c881764bcad4b3d169a507e2432643/crates/atuin/src/command/client/account/register.rs#L75-L111","documentation":"During `atuin register`, the server responded with AuthResponse::TwoFactorRequired. Two-factor is only expected during login, not account creation, so the CLI treats this as an unexpected server state and aborts. It indicates a mismatch between what the local client is doing (registration) and the server-side state of the account (which apparently already exists with 2FA enabled).","triggerScenarios":"Running `atuin register --username <u> --email <e> --password <p>` against a sync server where the username already has an account with two-factor authentication enabled, so the server replies TwoFactorRequired instead of a registration success.","commonSituations":"Re-registering against the same server after already creating an account; pointing sync_address at a server where the username is taken by a 2FA-enabled account; stale muscle memory trying to 'reset' an account by re-registering instead of logging in.","solutions":["Use `atuin login` (with your 2FA code when prompted) instead of `atuin register` — the account already exists.","Choose a different username if you truly want a new account.","Check you are pointing at the intended sync server (`sync.address` in config) — you may be hitting a different instance than expected.","If the old account is unwanted, delete it on the server before registering the same username."],"exampleFix":"// before\natuin register --username ellie --password '...'\n// error: unexpected two-factor requirement during registration\n// after\natuin login --username ellie   # enter password + 2FA code when prompted","handlingStrategy":"validation","validationCode":"# check whether the account exists before registering\natuin login --username \"$USER\" --password-stdin < /dev/null 2>&1 | grep -qi 'two-factor\\|incorrect' && echo 'account likely exists; use atuin login'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use `atuin login` for existing accounts, `atuin register` only for brand-new ones.","Keep one canonical sync_address in config to avoid hitting the wrong server.","Record which usernames are already registered on your sync server."],"tags":["auth","two-factor","registration","cli"],"backgroundTag":"unexpected-response-shape","analyzedSha":"c0c717ab04c881764bcad4b3d169a507e2432643","analyzedAt":"2026-09-12T07:40:01.341Z","contentChangedAt":"2026-09-12T07:40:01.341Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}