Skip to content

fix(init): add size guard and deduplicate JSON minification in preReadCommonFiles#713

Merged
betegon merged 1 commit intomainfrom
fix/preread-size-guard
Apr 10, 2026
Merged

fix(init): add size guard and deduplicate JSON minification in preReadCommonFiles#713
betegon merged 1 commit intomainfrom
fix/preread-size-guard

Conversation

@betegon
Copy link
Copy Markdown
Member

@betegon betegon commented Apr 10, 2026

Summary

Two fixes for preReadCommonFiles:

  1. Per-file size guard -- Stat files before reading and skip anything over MAX_FILE_BYTES (256KB). Prevents memory spikes from large files like Gemfile.lock that could eat the entire 512KB budget in one read.

  2. Deduplicate JSON minification -- Extract minifyJson() helper used by both preReadCommonFiles and readSingleFile. Prevents the two identical JSON.stringify(JSON.parse()) blocks from drifting out of sync.

Test plan

  • All 68 local-ops tests pass
  • Typecheck clean
  • Lint clean

Made with Cursor

…dCommonFiles

- Add stat check before reading files in preReadCommonFiles, skipping
  files larger than MAX_FILE_BYTES (256KB). Prevents memory spikes
  from large files like Gemfile.lock.

- Extract minifyJson() helper and use it in both preReadCommonFiles
  and readSingleFile to eliminate duplicated JSON.stringify(JSON.parse())
  logic.

Made-with: Cursor
@github-actions
Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Docs

  • Deploy main branch preview alongside PR previews by BYK in #707
  • Enable sourcemap upload, releases, and environment tracking by BYK in #705

Init

  • Pre-read common config files to reduce round-trips by betegon in #704
  • Add grep and glob local-op handlers by betegon in #703
  • Add fuzzy edit replacers and edits-based apply-patchset by betegon in #698

Other

  • (cli) Hoist global flags from any argv position and add -v alias by BYK in #709
  • (commands) Add buildRouteMap wrapper with standard subcommand aliases by BYK in #690
  • (config) Support .sentryclirc config file for per-directory defaults by BYK in #693
  • (install) Add SENTRY_INIT env var to run wizard after install by betegon in #685
  • (release) Surface adoption and health metrics in list and view (Add release command group with adoption/health subcommand #463) by BYK in #680
  • (telemetry) Add agent detection tag for AI coding tools by betegon in #687

Bug Fixes 🐛

Dashboard

  • Add --layout flag to widget add for predictable placement by BYK in #700
  • Render tracemetrics widgets in dashboard view by BYK in #695

Init

  • Add size guard and deduplicate JSON minification in preReadCommonFiles by betegon in #713
  • Narrow command validation to actual shell injection vectors by betegon in #697

Other

  • (build) Enable sourcemap resolution for compiled binaries by BYK in #701
  • (cache) --fresh flag now updates cache with fresh response by BYK in #708
  • (eval) Ground LLM judge with command reference to prevent false negatives by BYK in #712
  • (init,feedback) Default to tracing only in feature select and attach user email to feedback by MathurAditya724 in #688
  • (setup) Handle read-only .claude directory in sandboxed environments by BYK in #702
  • Inject auth token into generated .env.sentry-build-plugin files by MathurAditya724 in #706

Internal Changes 🔧

  • (docs) Gitignore generated command docs, extract fragments by BYK in #696
  • (eval) Replace OpenAI with Anthropic SDK in init-eval judge by betegon in #683
  • (init) Use markdown pipeline for spinner messages by betegon in #686
  • Regenerate skill files and command docs by github-actions[bot] in 584ec0e0

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

PR Preview Action v1.8.1

QR code for preview link

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

Built to branch gh-pages at 2026-04-10 17:48 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

Codecov Results 📊

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

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1573 uncovered lines.
✅ Project coverage is 95.36%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.36%    95.36%        —%
==========================================
  Files          232       232         —
  Lines        33927     33927         —
  Branches         0         0         —
==========================================
+ Hits         32354     32354         —
- Misses        1573      1573         —
- Partials         0         0         —

Generated by Codecov Action

@betegon betegon marked this pull request as ready for review April 10, 2026 18:11
@betegon betegon merged commit 2217947 into main Apr 10, 2026
24 checks passed
@betegon betegon deleted the fix/preread-size-guard branch April 10, 2026 18:38
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