Skip to content

refactor: fix double error wrapping and harden code quality#19

Merged
appleboy merged 1 commit intomainfrom
worktree-device-cli
Mar 24, 2026
Merged

refactor: fix double error wrapping and harden code quality#19
appleboy merged 1 commit intomainfrom
worktree-device-cli

Conversation

@appleboy
Copy link
Member

Summary

  • Eliminate double error wrapping on all 5 readResponseBody() call sites that produced "failed to read response: failed to read response: <err>"
  • Replace unsafe type assertion tokenStore.(*credstore.SecureStore[...]) with a local variable to prevent potential panics
  • Add tokenStoreModeAuto/File/Keyring constants to replace stringly-typed switch cases
  • Use specific error messages in exchangeDeviceCode and verifyToken for easier debugging
  • Remove obvious WHAT comments (e.g., // Create request with timeout, // Parse response) that duplicate code intent
  • Remove unnecessary generic type argument on NewSecureStore (caught by infertypeargs lint)

Test plan

  • make test — all tests pass
  • make lint — zero issues

🤖 Generated with Claude Code

- Eliminate double error wrapping on readResponseBody call sites
- Replace unsafe type assertion on SecureStore with local variable
- Add constants for token store backend modes (auto, file, keyring)
- Use specific error messages in exchangeDeviceCode and verifyToken
- Remove obvious WHAT comments that duplicate code intent
- Remove unnecessary generic type argument on NewSecureStore

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 24, 2026 13:12
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 13.33333% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
main.go 13.33% 13 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the CLI’s OAuth/token-storage flow to improve error propagation, reduce panic risk, and remove stringly-typed configuration while keeping behavior consistent.

Changes:

  • Eliminates double-wrapping of readResponseBody() errors across multiple HTTP call sites.
  • Replaces -token-store string literals with tokenStoreModeAuto/File/Keyring constants and removes an unsafe type assertion in the auto mode path.
  • Improves clarity of a few request failure error messages and removes redundant comments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@appleboy appleboy merged commit 0840b2f into main Mar 24, 2026
20 checks passed
@appleboy appleboy deleted the worktree-device-cli branch March 24, 2026 13:21
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.

3 participants