{"record":{"id":"cea0fa4af3eb4466","repo":"apache/answer","slug":"password-input-failed-w","errorCode":null,"errorMessage":"password input failed: %w","messagePattern":"password input failed: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/reset_password.go","lineNumber":133,"sourceCode":"\t\treturn fmt.Errorf(\"query user failed: %w\", err)\n\t}\n\tif !exist {\n\t\treturn fmt.Errorf(\"user not found: %s\", email)\n\t}\n\n\tfmt.Printf(\"You are going to reset password for user: %s\\n\", email)\n\n\tpassword := strings.TrimSpace(opts.Password)\n\n\tif password != \"\" {\n\t\tprintWarning(\"Passing password via command line may be recorded in shell history\")\n\t\tif err := checker.CheckPassword(password); err != nil {\n\t\t\treturn fmt.Errorf(\"password validation failed: %w\", err)\n\t\t}\n\t} else {\n\t\tpassword, err = promptForPassword()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"password input failed: %w\", err)\n\t\t}\n\t}\n\n\tif !confirmAction(fmt.Sprintf(\"This will reset password for user '[%s]%s'. Continue?\", userInfo.DisplayName, email)) {\n\t\tfmt.Println(\"Operation cancelled\")\n\t\treturn nil\n\t}\n\n\thashPwd, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"encrypt password failed: %w\", err)\n\t}\n\n\tif err = userRepo.UpdatePass(ctx, userInfo.ID, string(hashPwd)); err != nil {\n\t\treturn fmt.Errorf(\"update password failed: %w\", err)\n\t}\n\n\tauthSvc.RemoveUserAllTokens(ctx, userInfo.ID)","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/cli/reset_password.go#L115-L151","documentation":"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.","triggerScenarios":"Thrown at internal/cli/reset_password.go:133 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}