feat(debug-files): add bundle-sources command#1126
Merged
Conversation
Add `sentry debug-files bundle-sources <path>`: builds a source bundle (a ZIP stamped with the object's debug id) from the source files referenced by a debug information file, for upload to Sentry for source context. - src/lib/dif/index.ts: add `createSourceBundle()` over 13.4.0's `SourceBundleWriter` — walks the object's referenced source paths and invokes a caller-supplied provider for each (returning null skips files not available locally); returns the bundle bytes, debug id, and file count. - src/commands/debug-files/bundle-sources.ts: the command. Reads referenced sources from disk synchronously; defaults output to `<path>.src.zip` (`--output/-o` to override); exits non-zero (writing nothing) when no referenced sources are found on disk. Local-only, no API calls. - Extract the shared `readDebugFile` helper (read-file.ts) used by check + this. - Tests: createSourceBundle unit tests (Breakpad FILE-record fixture) + a bundle-sources command test. Docs fragment + generated skill/docs updated. Source files are read from the paths recorded in the debug info, so this is normally run on the build machine right after compiling.
Contributor
|
Contributor
Codecov Results 📊✅ Patch coverage is 94.34%. Project has 5047 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.28% 81.31% +0.03%
==========================================
Files 390 392 +2
Lines 26964 27009 +45
Branches 17521 17545 +24
==========================================
+ Hits 21918 21962 +44
- Misses 5046 5047 +1
- Partials 1822 1825 +3Generated by Codecov Action |
- Create the --output parent directory before writing (mirrors bundle-jvm), so '-o nested/dir/out.src.zip' works instead of failing with a raw ENOENT. - Warn when the archive has more than one object: only the first debug-info slice is bundled, so fat dSYMs aren't silently shortchanged. - Add objectCount to SourceBundleResult to drive that warning. - Tighten the command test (assert the 'Files bundled' row) and cover the missing-output-directory case.
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.
Adds
sentry debug-files bundle-sources <path>— builds a source bundle (a ZIP stamped with the object's debug id) from the source files referenced by a debug information file, for upload to Sentry to get source context in stack traces. Uses theSourceBundleWriterexposed in@sentry/symbolic13.4.0.Mirrors the legacy
sentry-cli difutil bundle-sourcesand rounds out the source tier alongsidecheck.Behavior
<path>.src.zip(--output/-oto override).Changes
src/lib/dif/index.ts:createSourceBundle()overSourceBundleWriter— caller supplies aprovider(path) => Uint8Array | null(null skips); returns{ bundle, debugId, fileCount }. The provider is invoked synchronously.src/commands/debug-files/bundle-sources.ts: the command (provider reads from disk viareadFileSync, ENOENT/unreadable →log.debug+ skip).src/commands/debug-files/read-file.ts: extracted the sharedreadDebugFilehelper (now used bycheckandbundle-sources).Tests
test/lib/dif/index.test.ts:createSourceBundle— bundles a referenced source supplied by the provider (BreakpadFILE-record fixture), empty/null-provider → no bundle, no-source-refs → no bundle, provider error surfaces as a throw, unparseable input throws.test/commands/debug-files/bundle-sources.test.ts: bundles a real on-disk source (tempFILEpath),--output, no-sources → exit 1 + nothing written, validation errors for missing/non-debug files.Validated locally:
tsc --noEmitclean, biome clean, dif + debug-files suites 31/31.