Skip to content

Improve error messages with context wrapping#24

Merged
fullstackjam merged 3 commits intomainfrom
claude/review-code-quality-UYhgi
Apr 19, 2026
Merged

Improve error messages with context wrapping#24
fullstackjam merged 3 commits intomainfrom
claude/review-code-quality-UYhgi

Conversation

@fullstackjam
Copy link
Copy Markdown
Collaborator

What does this PR do?

Wraps errors with contextual information throughout the codebase using fmt.Errorf with the %w verb, and fixes test flakiness by skipping permission-based tests when running as root.

Why?

Error wrapping provides better debugging experience by preserving the error chain while adding context about where the error occurred. This makes it easier to trace issues through the call stack. Additionally, some tests fail when run as root because the filesystem permission checks are bypassed, so those tests are now skipped in that environment.

Testing

  • go vet ./... passes
  • Relevant tests updated (added root permission checks to 5 test functions)
  • Existing tests continue to pass

Notes for reviewer

The changes are primarily mechanical error wrapping across multiple packages (dotfiles, shell, auth, npm, system). The test updates add guards to skip permission-related tests when running as root, which is a common issue in CI environments. One minor refactor changes brewInstallURL from a var to a const since it's never reassigned.

https://claude.ai/code/session_01JMUYrnrKTjytFqU1BVhKYA

@github-actions
Copy link
Copy Markdown

👋 Thanks for opening this pull request!

Before merging:

  • Code follows existing patterns in the codebase
  • go build ./... and go vet ./... pass
  • Commit message is clear and descriptive

@fullstackjam will review this soon. Thanks for contributing! 🚀

claude added 3 commits April 19, 2026 08:35
Add fmt.Errorf("context: %w", err) wrapping on previously bare
`return err` sites in auth, shell, npm, and dotfiles. Per
CLAUDE.md convention, callers should get contextual error chains.
Tests that rely on chmod 0500/0000 to trigger permission denied
silently succeed under root because root bypasses DAC checks,
leaving `err == nil` where the test expected a non-nil error and
panicking on the follow-up nil dereference. Guard these with
`os.Geteuid() == 0` skips; they still run as a non-root user or
in standard CI.
The existing comment described it as a test seam, but no test
reassigns it. A const prevents accidental mutation; if a test
ever needs to override the URL, add a proper seam then.
@fullstackjam fullstackjam force-pushed the claude/review-code-quality-UYhgi branch from 6115ebf to c290608 Compare April 19, 2026 08:35
@github-actions github-actions bot added the tests Tests only label Apr 19, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Codecov Report

❌ Patch coverage is 22.72727% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/dotfiles/dotfiles.go 18.18% 8 Missing and 1 partial ⚠️
internal/shell/shell.go 42.85% 3 Missing and 1 partial ⚠️
internal/auth/auth.go 0.00% 3 Missing ⚠️
internal/npm/npm.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@fullstackjam fullstackjam merged commit 1f5ef62 into main Apr 19, 2026
8 checks passed
@fullstackjam fullstackjam deleted the claude/review-code-quality-UYhgi branch April 19, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants