Skip to content

fix(auth): gracefully re-prompt on empty email during login#419

Open
theFong wants to merge 1 commit into
mainfrom
fix/register-empty-email-prompt
Open

fix(auth): gracefully re-prompt on empty email during login#419
theFong wants to merge 1 commit into
mainfrom
fix/register-empty-email-prompt

Conversation

@theFong

@theFong theFong commented Jul 2, 2026

Copy link
Copy Markdown
Member

Problem

Running brev register (or any login flow) and hitting enter with no input at the Enter your email: prompt produced a confusing error and a raw RESTY stack trace:

Enter your email:
failed.

2026/07/01 23:32:03 WARN RESTY [error] ...maybePromptForEmail... : unexpected newline

fmt.Scanln treats an empty line as an "unexpected newline" error, which was wrapped and propagated all the way up through the auth stack.

Fix

Replace the raw fmt.Scanln call in KasAuthenticator.maybePromptForEmail with the existing terminal.PromptGetInput helper (built on promptui, already used across ~10 commands). It validates input and re-prompts automatically on empty input, so entering a blank email now shows a friendly message instead of crashing.

Notes

  • The other branch of maybePromptForEmail (the "press enter to continue" confirmation) still uses fmt.Scanln, but it already tolerates the "unexpected newline" case, so it is unaffected by this bug and left unchanged to keep the diff focused.

Hitting enter with no input at the email prompt caused fmt.Scanln to
return an 'unexpected newline' error that surfaced as a confusing RESTY
stack trace. Use the existing terminal.PromptGetInput helper, which
validates and re-prompts on empty input.
@theFong theFong requested a review from a team as a code owner July 2, 2026 06:50
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.90%. Comparing base (83ace83) to head (90a82e3).
⚠️ Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
pkg/auth/kas.go 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #419      +/-   ##
==========================================
+ Coverage   20.09%   21.90%   +1.81%     
==========================================
  Files         140      137       -3     
  Lines       18451    18511      +60     
==========================================
+ Hits         3707     4055     +348     
+ Misses      14328    14004     -324     
- Partials      416      452      +36     
Flag Coverage Δ
Linux 21.90% <0.00%> (+1.81%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants