fix: add Glob.match() polyfill + improve auto-detect diagnostics (CLI-7T)#487
Merged
fix: add Glob.match() polyfill + improve auto-detect diagnostics (CLI-7T)#487
Conversation
) Three fixes for CLI-7T (ContextError: Organization and project are required): 1. Add missing match() to BunGlobPolyfill (script/node-polyfills.ts) The Node.js polyfill only had scan() — calling match() threw TypeError, silently swallowed by a bare catch {} in anyGlobMatches(). This broke project root detection for .NET (*.sln, *.csproj), Haskell (*.cabal), OCaml (*.opam), and Nim (*.nimble) on the npm distribution. Uses picomatch with dot:true to match Bun.Glob behavior. 2. Add debug logging to resolveAllTargets() (src/lib/resolve-target.ts) Each fallthrough step now logs at debug level so users can diagnose auto-detection failures with --verbose. 3. Add actionable alternatives to ContextError defaults (src/lib/errors.ts) Adds 'sentry org list' and 'sentry project list <org>/' hints so users who don't know their slugs have a clear next step. Fixes CLI-7T
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1037 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.77% 95.77% —%
==========================================
Files 180 180 —
Lines 24520 24534 +14
Branches 0 0 —
==========================================
+ Hits 23483 23497 +14
- Misses 1037 1037 —
- Partials 0 0 —Generated by Codecov Action |
Addresses Cursor BugBot review: picomatch was only available as a transitive dependency via tinyglobby. Adding it explicitly prevents breakage if tinyglobby ever changes its dependency tree.
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Addresses Cursor BugBot review: cache the compiled picomatch matcher in the constructor instead of recompiling on every match() call. Matches Bun.Glob semantics where the pattern is compiled once.
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.

Problem
When users run
sentry issue listorsentry issueswithout explicit org/project arguments, the auto-detection cascade fails withContextError: Organization and project are required.— 185 events affecting 63 users (CLI-7T).100% of events are from the Node.js/npm distribution (
cli.runtime: node), and 46% use--json(AI agents/tool callers).Root cause
The
BunGlobPolyfillclass in the Node.js polyfill was missing thematch()method. WhenanyGlobMatches()inproject-root.tscallednew Bun.Glob(pattern).match(name), it threw aTypeErrorthat was silently swallowed by a barecatch {}block. This broke project root detection for .NET (*.sln,*.csproj), Haskell (*.cabal), OCaml (*.opam), and Nim (*.nimble) projects on the npm distribution.While this bug is real, the primary cause for most users is simply running the CLI from a directory without a Sentry-instrumented project and with no env vars or config defaults set. The diagnostics and error message improvements help these users find the right path forward.
Fix
Add
match()toBunGlobPolyfill— Usespicomatch(already bundled viatinyglobby) with{dot: true}to matchBun.Globbehavior.Add debug logging to
resolveAllTargets()— Each fallthrough step (env vars → config defaults → DSN detection → directory inference) now logs at debug level, visible with--verbose.Improve
ContextErrordefault alternatives — Addssentry org listandsentry project list <org>/hints so users who don't know their slugs have a clear next step.Tests
Glob.match()covering allLANGUAGE_MARKER_GLOBSpatterns, negative cases, directory path rejection, and consistency with nativeBun.Glob.match().Fixes CLI-7T