Skip to content

fix: route auth errors to stderr and add actionable hints#145

Merged
scottlovegrove merged 2 commits intomainfrom
scottl/actionable-errors
Apr 5, 2026
Merged

fix: route auth errors to stderr and add actionable hints#145
scottlovegrove merged 2 commits intomainfrom
scottl/actionable-errors

Conversation

@scottlovegrove
Copy link
Copy Markdown
Collaborator

Summary

  • Routes OAuth failure messages in auth/login.ts to stderr via CliError (was using console.log to stdout, breaking agent JSON parsing)
  • Adds actionable hints arrays to ~15 CliError throws across auth, permissions, refs, view, skills, and oauth modules so AI agents can self-correct from errors

Closes #139

Test plan

  • npm run type-check passes
  • npm run lint:check passes
  • All 387 tests pass
  • tw auth login with no network — error goes to stderr with recovery hints
  • tw view https://example.com --json — structured JSON error includes hints array

🤖 Generated with Claude Code

- 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 doistbot requested a review from nvignola April 5, 2026 21:19
@scottlovegrove scottlovegrove self-assigned this Apr 5, 2026
@scottlovegrove scottlovegrove added the 👀 Show PR PR must be reviewed before or after merging label Apr 5, 2026
Copy link
Copy Markdown
Member

@doistbot doistbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Share FeedbackReview Logs

- 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>
@scottlovegrove scottlovegrove merged commit 3ab872c into main Apr 5, 2026
4 checks passed
@scottlovegrove scottlovegrove deleted the scottl/actionable-errors branch April 5, 2026 21:30
doist-release-bot bot added a commit that referenced this pull request Apr 5, 2026
## [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))
@doist-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.23.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

released 👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error messages: use stderr consistently and include actionable fix hints

2 participants