Skip to content

feat: implement dart-symbol-map upload command#1085

Merged
BYK merged 2 commits into
mainfrom
feat/dart-symbol-map
Jun 9, 2026
Merged

feat: implement dart-symbol-map upload command#1085
BYK merged 2 commits into
mainfrom
feat/dart-symbol-map

Conversation

@BYK

@BYK BYK commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

Part of #1055 — implements sentry dart-symbol-map upload, porting the legacy Rust sentry-cli's dart symbol map upload functionality.

What it does

Uploads Dart/Flutter obfuscation maps to Sentry for deobfuscating Dart exception types. Uses the DIF chunk-upload protocol (same as ProGuard uploads).

sentry dart-symbol-map upload --debug-id <uuid> mapping.json

How it works

  1. Validates the mapping file (JSON array of strings, even number of entries)
  2. Validates the debug ID format (UUID)
  3. Reads and chunks the file content using the DIF chunk-upload protocol
  4. Assembles via projects/{org}/{project}/files/difs/assemble/ with the debug ID
  5. Polls until assembly completes

Key design decision: --debug-id flag instead of companion debug file

The legacy Rust CLI accepts a companion native debug file (dSYM/ELF) and extracts the debug ID using the symbolic Rust crate. We can't parse native binaries in pure TS.

However, this is fine because the sentry-dart-plugin (the primary consumer) already extracts the debug ID via sentry-cli debug-files check before calling this command. So --debug-id <uuid> is the practical interface — no functionality is lost.

Flags

Flag Description
--debug-id / -d Required. Debug ID (UUID) from the companion native debug file
--no-upload Validate the file without uploading (no auth needed)
--json Machine-readable output

Validation

The mapping file must be:

  • Valid JSON
  • A JSON array (not object/string/etc.)
  • All entries must be strings
  • Even number of entries (alternating obfuscated/original name pairs)
  • Non-empty file

Files

File Purpose
src/lib/api/dart-symbols.ts DIF chunk-upload API module
src/commands/dart-symbol-map/upload.ts Command implementation
src/commands/dart-symbol-map/index.ts Route map
src/app.ts Route registration
test/commands/dart-symbol-map/upload.test.ts 11 tests

Testing

11 tests covering:

  • --no-upload dry-run (human + JSON output)
  • Invalid debug ID format rejection
  • Non-JSON file rejection
  • Non-array JSON rejection
  • Non-string array entries rejection
  • Odd entry count rejection
  • Empty file rejection
  • Nonexistent file rejection
  • Empty array acceptance (edge case)
  • -d alias for --debug-id

@BYK BYK added the enhancement New feature or request label Jun 9, 2026
@BYK BYK enabled auto-merge (squash) June 9, 2026 14:14
@BYK BYK force-pushed the feat/dart-symbol-map branch from 14700c7 to 1ddfa41 Compare June 9, 2026 15:52
@github-actions

github-actions Bot commented Jun 9, 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-1085/

Built to branch gh-pages at 2026-06-09 16:27 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1ddfa41. Configure here.

`Invalid debug ID format: '${debugId}'. Expected UUID format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,
"debug-id"
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug ID validation too strict

High Severity

validateDebugId only accepts a plain 36-character hyphenated UUID, but Sentry debug IDs from native companion files (e.g. dSYM) are often the full DebugId string with an optional lowercase hex appendix after the UUID. IDs from debug-files check in that form fail validation even though the upload API expects them.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1ddfa41. Configure here.

@BYK BYK force-pushed the feat/dart-symbol-map branch 3 times, most recently from dbc387c to 1cfb00e Compare June 9, 2026 16:17
Port the legacy `sentry-cli dart-symbol-map upload` command. Uploads
Dart/Flutter obfuscation maps to Sentry for deobfuscating Dart
exception types, using the DIF chunk-upload protocol.

Key design decisions:
- Requires `--debug-id <uuid>` flag (not a companion debug file)
  since native binary parsing requires the Rust `symbolic` crate.
  The sentry-dart-plugin already extracts the debug ID before calling
  this command, so `--debug-id` is the practical interface.
- Validates the map file is a JSON array of strings with even length
- `--no-upload` validates without uploading (no auth needed)
- Uses the same DIF assemble endpoint as ProGuard uploads:
  `projects/{org}/{project}/files/difs/assemble/`
- Includes `debug_id` in the assemble body to link the map to its
  companion native debug file (dSYM/ELF)

Files:
- src/lib/api/dart-symbols.ts \u2014 DIF chunk-upload API module
- src/commands/dart-symbol-map/upload.ts \u2014 command implementation
- src/commands/dart-symbol-map/index.ts \u2014 route map
- src/app.ts \u2014 route registration
- test/commands/dart-symbol-map/upload.test.ts \u2014 11 tests
@BYK BYK force-pushed the feat/dart-symbol-map branch from d139266 to 5d5223f Compare June 9, 2026 16:25
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

❌ Patch coverage is 46.51%. Project has 4970 uncovered lines.
❌ Project coverage is 81.29%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
src/lib/api/dart-symbols.ts 5.71% ⚠️ 33 Missing
src/commands/dart-symbol-map/upload.ts 74.00% ⚠️ 13 Missing and 4 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    81.41%    81.29%    -0.12%
==========================================
  Files          377       380        +3
  Lines        26480     26567       +87
  Branches     17251     17295       +44
==========================================
+ Hits         21559     21597       +38
- Misses        4921      4970       +49
- Partials      1788      1792        +4

Generated by Codecov Action

@BYK BYK merged commit 18944d5 into main Jun 9, 2026
29 checks passed
@BYK BYK deleted the feat/dart-symbol-map branch June 9, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant