{"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/c0c717ab04c881764bcad4b3d169a507e2432643/crates/atuin-client/src/api_client.rs#L128-L164","documentation":"Before registering, `register` probes `GET /user/{username}`. If that check succeeds (the username exists), registration would fail server-side, so the client bails early with 'username already in use'. Note this is triggered by a 2xx on the probe, not by reading a specific status code.","triggerScenarios":"Calling `atuin register` (or the `register` API function) with a username that already exists on the sync server, so `GET /user/{username}` returns success","commonSituations":"Re-running registration after a partial signup, trying a common username on a public sync server, or registering against a server where your old account still exists","solutions":["Choose a different username","If the existing account is yours, use `atuin login` instead of register","Delete the old account via the hub if you no longer want the name"],"exampleFix":"// before\natuin register -u alice -e a@b.c -p '...'\n// after\natuin register -u alice-2 -e a@b.c -p '...'  # or: atuin login -u alice","handlingStrategy":"validation","validationCode":"// probe the username before registering\nlet probe = client.get(format!(\"{address}/user/{username}\")).send().await?;\nif probe.status().is_success() {\n    eprintln!(\"username taken; choose another or use 'atuin login'\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"match register(&client, address, username, email, password).await {\n    Err(e) if e.to_string().contains(\"username already in use\") => {\n        prompt_alternate_username()\n    }\n    other => other,\n}","preventionTips":["Use distinctive usernames on shared sync servers","Use `atuin login` for existing accounts instead of re-registering","Handle the message in CLI wrappers by falling back to a username prompt"],"tags":["registration","api","conflict"],"backgroundTag":"api-error-response","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"}