{"record":{"id":"4f2cdb6f50b3bf75","repo":"atuinsh/atuin","slug":"failed-to-read-from-input","errorCode":null,"errorMessage":"Failed to read from input","messagePattern":"Failed to read from input","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin/src/command/client/account/change_password.rs","lineNumber":30,"sourceCode":"    #[clap(long, short)]\n    pub new_password: Option<String>,\n\n    /// The two-factor authentication code for your account, if any\n    #[clap(long, short)]\n    pub totp_code: Option<String>,\n}\n\nimpl Cmd {\n    pub async fn run(&self, settings: &Settings) -> Result<()> {\n        if !settings.logged_in().await? {\n            bail!(\"You are not logged in\");\n        }\n\n        let client = auth::auth_client(settings).await;\n\n        let current_password = self.current_password.clone().unwrap_or_else(|| {\n            prompt_password(\"Please enter the current password: \")\n                .expect(\"Failed to read from input\")\n        });\n\n        if current_password.is_empty() {\n            bail!(\"please provide the current password\");\n        }\n\n        let new_password = self.new_password.clone().unwrap_or_else(|| {\n            prompt_password(\"Please enter the new password: \").expect(\"Failed to read from input\")\n        });\n\n        if new_password.is_empty() {\n            bail!(\"please provide a new password\");\n        }\n\n        let mut totp_code = self.totp_code.clone();\n\n        loop {\n            let response = client","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/atuinsh/atuin/blob/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin/src/command/client/account/change_password.rs#L12-L48","documentation":"In `change_password.rs::run`, when `--current-password` was not supplied the command prompts interactively with `prompt_password(...)` and `.expect(\"Failed to read from input\")`s the result. The prompt fails when stdin cannot be read — EOF/closed stdin, non-interactive environments, or terminal read errors — causing a panic instead of a friendly CLI error.","triggerScenarios":"Running `atuin account change-password` without `--current-password` in a non-interactive context: piped/closed stdin, CI jobs, nohup, or scripts that don't allocate a TTY.","commonSituations":"Automation and CI pipelines invoking the password change; detached shells where no terminal is attached; users piping input that ends before the prompt reads it.","solutions":["Pass the current password explicitly with `--current-password <pw>` (avoiding the prompt)","Run the command in an interactive terminal","If scripting, pipe the password via stdin ensuring stdin stays open until the prompt completes"],"exampleFix":"// before\nlet current_password = self.current_password.clone().unwrap_or_else(|| {\n    prompt_password(\"Please enter the current password: \")\n        .expect(\"Failed to read from input\")\n});\n// after\nlet current_password = match self.current_password.clone() {\n    Some(p) => p,\n    None => match prompt_password(\"Please enter the current password: \") {\n        Ok(p) => p,\n        Err(e) => bail!(\"failed to read current password from input: {e}\"),\n    },\n};","handlingStrategy":"validation","validationCode":"// check interactivity before prompting\nif atty::is(atty::Stream::Stdin) || std::env::var_os(\"ATUIN_CURRENT_PASSWORD\").is_some() { /* safe to prompt */ }","typeGuard":null,"tryCatchPattern":"match prompt_password(\"Please enter the current password: \") {\n    Ok(p) => p,\n    Err(e) => bail!(\"could not read current password (is stdin a terminal?): {e}\"),\n}","preventionTips":["Always pass --current-password in scripts and CI","Support reading the password from an env var or stdin for non-interactive use","Check stdin is a TTY before prompting and emit an actionable error otherwise"],"tags":["panic","stdin","cli","interactive","password"],"backgroundTag":"missing-cli-argument","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"}