fix: surface actionable error when config file is not writable#153
Merged
fix: surface actionable error when config file is not writable#153
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the CLI’s handling of permission issues with the user config file (.capawesome) by converting low-level filesystem access errors into actionable UserErrors that are excluded from Sentry reporting.
Changes:
- Catch config read/write permission failures in
UserConfigImpland rethrow a guidance-focusedUserError. - Add
getCodeFromUnknownErrorutility to safely extract an errorcodefromunknownerrors for branching (e.g.,EACCESchecks).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/utils/user-config.ts |
Wraps rc9 read/write failures to surface actionable permission-denied remediation to the user. |
src/utils/error.ts |
Adds getCodeFromUnknownError helper used to detect access-denied errors safely. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.capawesome config file is not writable
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
~/.capawesomebecause of OS permissions (e.g. the file was created during a previoussudorun and is now owned byroot), it threw a rawEACCESthat bubbled up to Sentry with no guidance for the user.UserConfigImpl.read/writenow catch the failure and re-throw aUserErrorcarrying the resolved path and a suggested remediation (chownorrm).UserErroris already filtered out of Sentry reporting insrc/index.ts, so these environment issues stop polluting the issue tracker.getCodeFromUnknownErrorinsrc/utils/error.tsto extractcodefrom unknown errors in a type-safe way, and used it for theEACCEScheck.Test plan
npx tsc --noEmitnpx vitest run src/commands/login.test.ts src/commands/logout.test.ts src/commands/whoami.test.tsnpm run fmt