{"record":{"id":"2a0241e2d3e4774f","repo":"atuinsh/atuin","slug":"username-already-in-use","errorCode":null,"errorMessage":"username already in use","messagePattern":"username already in use","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin-client/src/api_client.rs","lineNumber":146,"sourceCode":"    password: &str,\n    extra_headers: &HashMap<String, String>,\n) -> Result<RegisterResponse> {\n    let mut map = HashMap::new();\n    map.insert(\"username\", username);\n    map.insert(\"email\", email);\n    map.insert(\"password\", password);\n\n    let mut headers = extra_headers_map(extra_headers)?;\n    headers.insert(USER_AGENT, APP_USER_AGENT.parse()?);\n    headers.insert(ATUIN_HEADER_VERSION, ATUIN_CARGO_VERSION.parse()?);\n\n    let client = client_builder(extra_headers).build()?;\n\n    let url = address.append([\"user\", username])?;\n    let resp = client.get(url).headers(headers.clone()).send().await?;\n\n    if resp.status().is_success() {\n        bail!(\"username already in use\");\n    }\n\n    let url = address.append([\"register\"])?;\n    let resp = client.post(url).headers(headers).json(&map).send().await?;\n    let resp = handle_resp_error(resp).await?;\n\n    if !ensure_version(&resp)? {\n        bail!(\"could not register user due to version mismatch\");\n    }\n\n    let session = resp.json::<RegisterResponse>().await?;\n    Ok(session)\n}\n\n#[instrument(level = \"trace\", skip_all, err)]\npub async fn login(\n    address: &Url,\n    req: LoginRequest,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/atuinsh/atuin/blob/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin-client/src/api_client.rs#L128-L164","documentation":"`register` first probes `GET /user/<username>`; if the server responds with success, the username is already taken and registration aborts with this error. The actual `POST /register` is never attempted.","triggerScenarios":"Calling `atuin register` (or `register()` in api_client) with a username that already exists on the sync server.","commonSituations":"Re-running registration on a machine where you already signed up, choosing a common username, or pointing at a server where your username is claimed by someone else.","solutions":["Run `atuin login -u <username>` instead — you likely already have an account","Choose a different username for registration","Check for typos in the username","If you lost your password, use the server's account recovery rather than re-registering"],"exampleFix":"// before\natuin register -u alice -e a@b.c -p 'pass'\n// after (account exists)\natuin login -u alice","handlingStrategy":"validation","validationCode":"// before register, probe the username the same way the client does\nlet probe = client.get(format!(\"{address}/user/{username}\")).send().await?;\nif probe.status().is_success() {\n    eprintln!(\"username taken — use `atuin login` instead\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"match register(&client, &address, username, email, password).await {\n    Err(e) if e.to_string() == \"username already in use\" => {\n        login(&client, &address, username, password).await? // fall back to login\n    }\n    other => other?,\n}","preventionTips":["Prefer `atuin login` when an account may already exist","Pick a distinctive username","Keep the registration password recorded so re-registration isn't tempting"],"tags":["registration","api","conflict"],"backgroundTag":"api-error-response","analyzedSha":"900007c48045867e7f44b0f9bc55ad9dbe99ee0d","analyzedAt":"2026-09-19T12:52:51.491Z","contentChangedAt":"2026-09-19T12:52:51.491Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}