fix(hello): validate login inputs with actionable hints#24
Conversation
Telemetry on v0.18.x shows a small but persistent "deployhq: api key
is required" bucket on `dhq hello` (2 hits / 30d). The cause: the
masked API-key prompt accepts an empty Enter, then sdk.New surfaces
the SDK's internal validation message verbatim — users see a cryptic
"deployhq:" prefixed string with no guidance on where to find the key.
- New validateHelloLoginInputs runs after the prompts and before
sdk.New, returning a UserError per missing field with a hint that
points at the source of each value. The API-key hint names the
DeployHQ UI path ("Profile → API Key") and tells users to re-run
the command.
- The headline strings ("Account is required" / "Email is required" /
"API key is required") drop the "deployhq:" SDK prefix so the new
telemetry buckets are immediately recognisable.
- Five test cases cover the success path, each missing-field branch,
and the first-failure-wins ordering so users fix one thing at a time.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR adds early input validation to the hello login command. A new ChangesHello login input validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
dhq helloshows a small but persistentdeployhq: api key is requiredbucket on Mixpanel (2 hits / 30d on v0.18.x). The masked API-key prompt accepts an empty Enter, thensdk.Newsurfaces its internal validation string verbatim. Users see a crypticdeployhq:-prefixed message with no guidance on where to find the key.internal/commands/hello.go— newvalidateHelloLoginInputs(account, email, apiKey)runs after the prompts and beforesdk.New, returning aUserErrorper missing field. Each error has a hint that points at the source of that value; the API-key hint names the DeployHQ UI path ("Profile → API Key") and tells the user to re-rundhq hello. Headlines drop thedeployhq:prefix so the new telemetry buckets are immediately readable.internal/commands/hello_test.go— five table-driven cases: success path, each missing-field branch, and first-failure-wins ordering (so users only fix one thing at a time). Headline assertions go throughstrings.SplitN(err.Error(), "\n", 2)[0]to mirror whattelemetry.SanitizeErrorMessageactually sees.What this doesn't try to do
dhq hellois short enough that a re-run is cheap, and the explicit hint covers the path.Test plan
go test ./...— all packages greengolangci-lint run ./...— 0 issues🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests