fix: route auth errors to stderr and add actionable hints#145
fix: route auth errors to stderr and add actionable hints#145scottlovegrove merged 2 commits intomainfrom
Conversation
- Replace console.log error output in auth/login.ts with CliError throw so OAuth failures go to stderr and respect --json - Add recovery hints to errors across auth, permissions, refs, view, skills, and oauth modules so agents can self-correct Closes #139 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
doistbot
left a comment
There was a problem hiding this comment.
This PR nicely improves error handling by routing OAuth failures to stderr and introducing actionable hints across multiple modules to help users and AI agents recover from failures. These additions will significantly enhance the developer experience and make the CLI's error output much more robust. There are just a few areas to refine before merging, specifically addressing a security concern with suggesting API tokens in CLI arguments, ensuring hints are attached to explicit OAuth error throws rather than just the fallback catch block, and strengthening the tests to verify the global error path and structured JSON output.
- Replace tw auth token <token> hints with safe alternatives (interactive prompt or TWIST_API_TOKEN env var) to avoid exposing secrets in shell history - Attach AUTH_HINTS to all explicit CliError throws in oauth.ts, not just the catch-all fallbacks - Add hints assertion to auth login error tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
## [2.23.3](v2.23.2...v2.23.3) (2026-04-05) ### Bug Fixes * route auth errors to stderr and add actionable hints ([#145](#145)) ([3ab872c](3ab872c))
|
🎉 This PR is included in version 2.23.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
auth/login.tsto stderr viaCliError(was usingconsole.logto stdout, breaking agent JSON parsing)hintsarrays to ~15CliErrorthrows across auth, permissions, refs, view, skills, and oauth modules so AI agents can self-correct from errorsCloses #139
Test plan
npm run type-checkpassesnpm run lint:checkpassestw auth loginwith no network — error goes to stderr with recovery hintstw view https://example.com --json— structured JSON error includes hints array🤖 Generated with Claude Code