fix(dsn): make code scanner monorepo-aware and extend --fresh to bypass DSN cache#420
Merged
fix(dsn): make code scanner monorepo-aware and extend --fresh to bypass DSN cache#420
Conversation
The code scanner used MAX_SCAN_DEPTH=2 which couldn't reach files inside monorepo packages (e.g., packages/spotlight/src/instrument.ts at depth 3). The packages/ prefix consumed the full depth budget, leaving nothing for src/. Bump MAX_SCAN_DEPTH to 3 and reset depth to 0 when entering a monorepo package directory (packages/*, apps/*, etc.), giving each package its own depth budget. This matches how the env file scanner already handles monorepos. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Init
Issue List
Other
Bug Fixes 🐛Dsn
Init
Other
Documentation 📚
Internal Changes 🔧Init
Other
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 111 passed | Total: 111 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 96.43%. Project has 1065 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.02% 95.03% +0.01%
==========================================
Files 159 159 —
Lines 21404 21428 +24
Branches 0 0 —
==========================================
+ Hits 20339 20363 +24
- Misses 1065 1065 —
- Partials 0 0 —Generated by Codecov Action |
After the scanner fix, stale cached results (with fewer DSNs) survive because mtime validation only checks files that were previously found. Users had no way to force a re-scan short of manually clearing SQLite. Add disableDsnCache()/enableDsnCache() following the same pattern as disableResponseCache(), and wire it into applyFreshFlag() so --fresh now bypasses both HTTP response cache and DSN detection cache. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add projects, plugins, sites, workers, and functions to the list of recognized monorepo root directories. These cover Google-style monorepos, WordPress/Grafana plugin repos, multi-site setups, Cloudflare Workers, and AWS Lambda serverless monorepos respectively. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add test for deeply nested monorepo files (depth 5 from root, the specific case from the original bug) and a negative test confirming non-monorepo directories still respect the depth limit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
The DSN code scanner missed files inside monorepo packages because
MAX_SCAN_DEPTH=2couldn't reach pastpackages/<name>/src/. For example, in the spotlight monorepo only 1 of 3 DSNs was detected —packages/website/sentry.client.config.mjsat depth 2 was found, butpackages/spotlight/src/instrument.tsat depth 3 was not.Even after fixing the scanner, stale cached results survive because mtime validation only checks files that were previously found — files missed by the old depth limit have no cache entries. Users had no way to force a re-scan.
Changes
Scanner fix:
MAX_SCAN_DEPTHfrom 2 to 3 (also helps non-monorepo projects with deeper configs likesrc/lib/config/sentry.ts)packages/*,apps/*,libs/*,services/*,modules/*), giving each package its own depth-3 scanning budgetMONOREPO_ROOTSconstant fromtypes.ts, matching how the env file scanner already handles monoreposCache bypass (
--fresh):disableDsnCache()/enableDsnCache()following the same pattern asdisableResponseCache()applyFreshFlag()so--freshnow bypasses both HTTP response cache and DSN detection cacheTest plan
packagePathgetCachedDsn/getCachedDetectionreturn undefined when cache disabled, writes persistsentry issue list --freshfrom spotlight monorepo, verify multiple projects detected🤖 Generated with Claude Code