Skip to content

feat(debug-files): add bundle-sources command#1126

Merged
BYK merged 2 commits into
mainfrom
byk/feat/debug-files-bundle-sources
Jun 23, 2026
Merged

feat(debug-files): add bundle-sources command#1126
BYK merged 2 commits into
mainfrom
byk/feat/debug-files-bundle-sources

Conversation

@BYK

@BYK BYK commented Jun 23, 2026

Copy link
Copy Markdown
Member

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 the SourceBundleWriter exposed in @sentry/symbolic 13.4.0.

Mirrors the legacy sentry-cli difutil bundle-sources and rounds out the source tier alongside check.

Behavior

  • Parses the debug file in-process (Mach-O/dSYM, ELF, PE/PDB, Portable PDB, WASM, Breakpad), walks the object's referenced source paths, and reads each from disk.
  • Source files are read from the paths recorded in the debug info, so this is normally run on the build machine right after compiling. Referenced files not present locally are skipped.
  • Default output: <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.

Changes

  • src/lib/dif/index.ts: createSourceBundle() over SourceBundleWriter — caller supplies a provider(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 via readFileSync, ENOENT/unreadable → log.debug + skip).
  • src/commands/debug-files/read-file.ts: extracted the shared readDebugFile helper (now used by check and bundle-sources).
  • Docs fragment + generated skill/contributing updated.

Tests

  • test/lib/dif/index.test.ts: createSourceBundle — bundles a referenced source supplied by the provider (Breakpad FILE-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 (temp FILE path), --output, no-sources → exit 1 + nothing written, validation errors for missing/non-debug files.

Validated locally: tsc --noEmit clean, biome clean, dif + debug-files suites 31/31.

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.
@github-actions

github-actions Bot commented Jun 23, 2026

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-1126/

Built to branch gh-pages at 2026-06-23 13:46 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 94.34%. Project has 5047 uncovered lines.
✅ Project coverage is 81.31%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
src/commands/debug-files/bundle-sources.ts 96.30% ⚠️ 1 Missing and 2 partials
src/lib/dif/index.ts 94.12% ⚠️ 1 Missing and 2 partials
src/commands/debug-files/read-file.ts 88.89% ⚠️ 1 Missing and 1 partials
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        +3

Generated 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.
@BYK BYK merged commit 9784fb5 into main Jun 23, 2026
29 checks passed
@BYK BYK deleted the byk/feat/debug-files-bundle-sources branch June 23, 2026 13:56
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