Skip to content

fix(completions): handle permission errors gracefully in installCompletions (CLI-1A5)#867

Merged
BYK merged 7 commits intomainfrom
fix/cli-1a5-eperm-completions-setup
Apr 28, 2026
Merged

fix(completions): handle permission errors gracefully in installCompletions (CLI-1A5)#867
BYK merged 7 commits intomainfrom
fix/cli-1a5-eperm-completions-setup

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 28, 2026

Summary

  • installCompletions now catches EPERM, EACCES, and EROFS filesystem errors and returns null instead of throwing
  • Prevents noisy Sentry error reports (CLI-1A5, 17 users, 31 events) when the completion target directory is not writable
  • Common on macOS where ~/.local/share/zsh may be protected by SIP or owned by root, and during Homebrew post-install with restrictive permissions

Changes

  • src/lib/completions.ts: Wrap the mkdirSync + Bun.write calls in a try/catch that detects permission error codes and returns null gracefully
  • test/lib/completions.test.ts: Add tests for EACCES and EPERM scenarios using chmodSync to simulate restricted directories

Fixes https://sentry.sentry.io/issues/7423432325/

BYK added 5 commits April 28, 2026 21:40
…etions (CLI-1A5)

installCompletions now catches EPERM, EACCES, and EROFS filesystem errors
and returns null instead of throwing. This prevents noisy Sentry reports
when the completion target directory is not writable (common on macOS with
SIP-protected paths or during Homebrew post-install).
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-867/

Built to branch gh-pages at 2026-04-28 22:33 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

The setup test expected bestEffort to catch the EPERM error, but now
installCompletions handles it internally and returns null. Update the
test to verify setup completes without error messages.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

Codecov Results 📊

6215 passed | Total: 6215 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +2
Passed Tests 📈 +2
Failed Tests
Skipped Tests

All tests are passing successfully.

❌ Patch coverage is 66.67%. Project has 12867 uncovered lines.
✅ Project coverage is 76.09%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
src/lib/completions.ts 67.74% ⚠️ 10 Missing
src/commands/cli/setup.ts 58.33% ⚠️ 5 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    75.90%    76.09%    +0.19%
==========================================
  Files          293       293         —
  Lines        53943     53822      -121
  Branches         0         0         —
==========================================
+ Hits         40947     40955        +8
- Misses       12996     12867      -129
- Partials         0         0         —

Generated by Codecov Action

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 39bc7ec. Configure here.

Comment thread src/lib/completions.ts
…rmission errors

When installCompletions returns null for a supported shell (bash/zsh/fish)
due to permission errors, don't fall through to tryBashCompletionFallback
which would misleadingly say 'Your shell (zsh) is not directly supported'.
Skip the fallback for all shells with native completion support.

Addresses Cursor Bugbot review comment.
@BYK BYK merged commit b4b68df into main Apr 28, 2026
26 checks passed
@BYK BYK deleted the fix/cli-1a5-eperm-completions-setup branch April 28, 2026 22:39
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.

1 participant