Skip to content

fix: surface actionable error when config file is not writable#153

Merged
robingenz merged 3 commits intomainfrom
fix/user-config-eacces
Apr 23, 2026
Merged

fix: surface actionable error when config file is not writable#153
robingenz merged 3 commits intomainfrom
fix/user-config-eacces

Conversation

@robingenz
Copy link
Copy Markdown
Member

Summary

  • When the CLI cannot read or write ~/.capawesome because of OS permissions (e.g. the file was created during a previous sudo run and is now owned by root), it threw a raw EACCES that bubbled up to Sentry with no guidance for the user.
  • UserConfigImpl.read / write now catch the failure and re-throw a UserError carrying the resolved path and a suggested remediation (chown or rm). UserError is already filtered out of Sentry reporting in src/index.ts, so these environment issues stop polluting the issue tracker.
  • Added getCodeFromUnknownError in src/utils/error.ts to extract code from unknown errors in a type-safe way, and used it for the EACCES check.

Test plan

  • npx tsc --noEmit
  • npx vitest run src/commands/login.test.ts src/commands/logout.test.ts src/commands/whoami.test.ts
  • npm run fmt

Copilot AI review requested due to automatic review settings April 22, 2026 11:59
Copy link
Copy Markdown
Contributor

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

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 UserConfigImpl and rethrow a guidance-focused UserError.
  • Add getCodeFromUnknownError utility to safely extract an error code from unknown errors for branching (e.g., EACCES checks).

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.

Comment thread src/utils/user-config.ts Outdated
Comment thread src/utils/user-config.ts Outdated
Comment thread src/utils/user-config.ts Outdated
Comment thread src/utils/user-config.ts
@robingenz robingenz requested a review from Copilot April 23, 2026 04:41
@robingenz robingenz changed the title fix: surface actionable error when .capawesome config file is not writable fix: surface actionable error when config file is not writable Apr 23, 2026
@robingenz robingenz self-assigned this Apr 23, 2026
@robingenz robingenz added the bug/fix Something isn't working label Apr 23, 2026
Copy link
Copy Markdown
Contributor

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

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.

Comment thread src/utils/user-config.ts
Comment thread src/utils/user-config.ts Outdated
@robingenz robingenz merged commit ab8ed4c into main Apr 23, 2026
3 checks passed
@robingenz robingenz deleted the fix/user-config-eacces branch April 23, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug/fix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants