apache/answer · error
password input failed: %w
Error message
password input failed: %w
What it means
Fires in ResetPassword when the interactive prompt promptForPassword fails — typically term.ReadPassword cannot read from stdin because it is not a TTY (piped/non-interactive execution) or the terminal read errors. The at-fault input is the interactive stdin stream, not a stored password.
Source
Thrown at internal/cli/reset_password.go:133
return fmt.Errorf("query user failed: %w", err)
}
if !exist {
return fmt.Errorf("user not found: %s", email)
}
fmt.Printf("You are going to reset password for user: %s\n", email)
password := strings.TrimSpace(opts.Password)
if password != "" {
printWarning("Passing password via command line may be recorded in shell history")
if err := checker.CheckPassword(password); err != nil {
return fmt.Errorf("password validation failed: %w", err)
}
} else {
password, err = promptForPassword()
if err != nil {
return fmt.Errorf("password input failed: %w", err)
}
}
if !confirmAction(fmt.Sprintf("This will reset password for user '[%s]%s'. Continue?", userInfo.DisplayName, email)) {
fmt.Println("Operation cancelled")
return nil
}
hashPwd, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
if err != nil {
return fmt.Errorf("encrypt password failed: %w", err)
}
if err = userRepo.UpdatePass(ctx, userInfo.ID, string(hashPwd)); err != nil {
return fmt.Errorf("update password failed: %w", err)
}
authSvc.RemoveUserAllTokens(ctx, userInfo.ID)View on GitHub (pinned to 3b9f137061)
Solutions
- Retry the command; the failure usually comes from term.ReadPassword on stdin
- Run the command in an interactive TTY instead of piping stdin or redirecting input
- If no TTY is available, pass the password via the --password flag (with the shell-history caveat) or pre-generate one
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/cli/reset_password.go:133 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05).
Data as JSON: /api/errors/cea0fa4af3eb4466.
Report an issue: GitHub.