{"record":{"id":"62426a3305d20fe1","repo":"atuinsh/atuin","slug":"no-encryption-key-provided","errorCode":null,"errorMessage":"No encryption key provided","messagePattern":"No encryption key provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin/src/command/client/account/login.rs","lineNumber":210,"sourceCode":"        println!(\"IMPORTANT\");\n        println!(\n            \"If you are already logged in on another machine, you must ensure that the key you \\\n             use here is the same as the key you used there.\"\n        );\n        println!(\"You can find your key by running 'atuin key' on the other machine.\");\n        println!(\"Do not share this key with anyone.\");\n        println!(\"\\nRead more here: {} \\n\", atuin_common::docs::url(\"guide/sync/#login\"));\n\n        let interactive = self.interactive();\n        let mut flag_key = self.key.clone();\n\n        loop {\n            let key = match flag_key.take() {\n                Some(key) => key,\n                None => match read_user_input(\"encryption key [blank to use existing key file]\") {\n                    Some(key) => key,\n                    // Stdin is exhausted, so re-prompting would spin forever.\n                    None => bail!(\"No encryption key provided\"),\n                },\n            };\n\n            if key.is_empty() {\n                if !key_path.exists() {\n                    let msg = \"No key provided and no existing key file found. Please use 'atuin \\\n                               key' on your other machine, or recover your key from a backup\";\n                    if !interactive {\n                        bail!(msg);\n                    }\n                    println!(\"\\n{msg}\\n\");\n                    continue;\n                }\n\n                paseto_v4::Key::try_load_from_path(key_path).context(format!(\n                    \"The key in existing key file at '{}' is invalid\",\n                    key_path.to_string_lossy()\n                ))?;","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/atuinsh/atuin/blob/c0c717ab04c881764bcad4b3d169a507e2432643/crates/atuin/src/command/client/account/login.rs#L192-L228","documentation":"During login, atuin needs the account's encryption key. If no key was supplied via `--key` and the interactive read from stdin returns None (stdin exhausted, e.g. non-interactive runs), prompt_and_store_key bails immediately — re-prompting would loop forever.","triggerScenarios":"Running `atuin login` without `--key` in a non-interactive context: `atuin login < /dev/null`, CI scripts, or piping credentials so stdin is exhausted before the key prompt reads.","commonSituations":"Automated login in CI/Docker where prompts cannot be answered; piping output from another command that consumes stdin; forgetting the --key flag while scripting; running under a wrapper that closes stdin.","solutions":["Pass the key explicitly: `atuin login --key <your-key>` (or via env/flag in your automation)","Run `atuin login` in a real interactive terminal so the prompt can read input","If an existing key file should be reused, pass an empty line interactively or ensure key_path exists","Retrieve the key from the original machine with `atuin key` and supply it here"],"exampleFix":"// before: stdin exhausted -> bail\natuin login < /dev/null\n\n// after\natuin login --key \"<your-encryption-key>\"","handlingStrategy":"validation","validationCode":"[ -n \"$ATUIN_KEY\" ] || { echo 'encryption key required for non-interactive login' >&2; exit 1; }\natuin login --key \"$ATUIN_KEY\"","typeGuard":null,"tryCatchPattern":"if ! atuin login --key \"$ATUIN_KEY\"; then\n  echo \"Login failed — key was missing or rejected\" >&2\nfi","preventionTips":["Always pass --key when logging in from scripts/CI","Run `atuin key` on the source machine and store the key in a secrets manager","Provide a TTY when interactive prompts are expected","Never pipe stdin into atuin login unless all inputs are supplied via flags"],"tags":["cli","encryption","key","stdin"],"backgroundTag":"missing-credentials","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"}