{"record":{"id":"e827ac87c5c1553e","repo":"amir20/dozzle","slug":"failed-to-read-password-from-stdin-w","errorCode":null,"errorMessage":"failed to read password from stdin: %w","messagePattern":"failed to read password from stdin: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/support/cli/generate_command.go","lineNumber":79,"sourceCode":"// they don't pollute stdout (which is commonly redirected to users.yml). When\n// stdin is a terminal the input is read without echo; otherwise a single line\n// is read (supports piping, e.g. `echo secret | dozzle generate ...`).\nfunc readPassword() (string, error) {\n\tfd := int(os.Stdin.Fd())\n\tif term.IsTerminal(fd) {\n\t\tfmt.Fprint(os.Stderr, \"Password: \")\n\t\tbytePassword, err := term.ReadPassword(fd)\n\t\tfmt.Fprintln(os.Stderr)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to read password: %w\", err)\n\t\t}\n\t\treturn strings.TrimRight(string(bytePassword), \"\\r\\n\"), nil\n\t}\n\n\treader := bufio.NewReader(os.Stdin)\n\tline, err := reader.ReadString('\\n')\n\tif err != nil && line == \"\" {\n\t\treturn \"\", fmt.Errorf(\"failed to read password from stdin: %w\", err)\n\t}\n\treturn strings.TrimRight(line, \"\\r\\n\"), nil\n}\n","sourceCodeStart":61,"sourceCodeEnd":83,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/support/cli/generate_command.go#L61-L83","documentation":"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'.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\ndozzle generate < /dev/null\n// after\necho \"$PASSWORD\" | dozzle generate","handlingStrategy":"validation","validationCode":"if [ ! -t 0 ]; then\n  if [ -z \"$PASSWORD\" ]; then echo 'refusing: empty stdin for password' >&2; exit 1; fi\nfi\necho \"$PASSWORD\" | dozzle generate","typeGuard":null,"tryCatchPattern":"if ! echo \"$PASSWORD\" | dozzle generate; then\n  echo \"failed to supply password\" >&2\nfi","preventionTips":["Never invoke dozzle generate with empty/closed stdin in non-interactive mode","Ensure pipes stay open until the writer has flushed the password line"],"tags":["cli","stdin","pipe"],"backgroundTag":"missing-cli-argument","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}