Improve error messages with context wrapping#24
Merged
fullstackjam merged 3 commits intomainfrom Apr 19, 2026
Merged
Conversation
|
👋 Thanks for opening this pull request! Before merging:
@fullstackjam will review this soon. Thanks for contributing! 🚀 |
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.
6115ebf to
c290608
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Wraps errors with contextual information throughout the codebase using
fmt.Errorfwith the%wverb, 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 ./...passesNotes 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 changesbrewInstallURLfrom avarto aconstsince it's never reassigned.https://claude.ai/code/session_01JMUYrnrKTjytFqU1BVhKYA