amir20/dozzle · error
failed to read password from stdin
Error message
failed to read password from stdin: %w
What it means
When stdin is not a terminal, `readPassword` falls back to a bufio line read from stdin. If ReadString fails and no partial line was read (e.g. EOF with empty input), the error is wrapped as 'failed to read password from stdin'.
Solutions
- Provide the password on stdin: `echo 'mypassword' | dozzle generate` or a heredoc
- Ensure the pipe writer stays open until the line is delivered
- Verify the script actually contains a non-empty password before the pipe
Example fix
// before dozzle generate < /dev/null // after echo "$PASSWORD" | dozzle generate
Defensive patterns
Strategy: validation
Validate before calling
if [ ! -t 0 ]; then if [ -z "$PASSWORD" ]; then echo 'refusing: empty stdin for password' >&2; exit 1; fi fi echo "$PASSWORD" | dozzle generate
Try / catch
if ! echo "$PASSWORD" | dozzle generate; then echo "failed to supply password" >&2 fi
Prevention
- Never invoke dozzle generate with empty/closed stdin in non-interactive mode
- Ensure pipes stay open until the writer has flushed the password line
When it happens
Trigger: Running `dozzle generate` with piped/redirected stdin that is empty or closed: `dozzle generate < /dev/null`, or a pipe whose writer closed before sending a line (EOF).
Common situations: CI jobs that invoke the command without providing the password on stdin; shell scripts where the heredoc/pipe is empty; missing password in non-interactive automation.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
- failed to read password
- agent command is only available in server mode
- error reading certificates
- username is required
- password is required
AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07).
Data as JSON: /api/errors/e827ac87c5c1553e.
Report an issue: GitHub.
Appendix: source
Thrown at internal/support/cli/generate_command.go:79
// they don't pollute stdout (which is commonly redirected to users.yml). When
// stdin is a terminal the input is read without echo; otherwise a single line
// is read (supports piping, e.g. `echo secret | dozzle generate ...`).
func readPassword() (string, error) {
fd := int(os.Stdin.Fd())
if term.IsTerminal(fd) {
fmt.Fprint(os.Stderr, "Password: ")
bytePassword, err := term.ReadPassword(fd)
fmt.Fprintln(os.Stderr)
if err != nil {
return "", fmt.Errorf("failed to read password: %w", err)
}
return strings.TrimRight(string(bytePassword), "\r\n"), nil
}
reader := bufio.NewReader(os.Stdin)
line, err := reader.ReadString('\n')
if err != nil && line == "" {
return "", fmt.Errorf("failed to read password from stdin: %w", err)
}
return strings.TrimRight(line, "\r\n"), nil
}
View on GitHub (pinned to d9463cbe21)