feat(wasm-split): port Symbolicator wasm-split - #1589
Conversation
- Add `sentry wasm-split` with the same flags and stdout contract as the Rust tool Co-authored-by: Cursor <cursoragent@cursor.com>
- Reject unknown section ids and out-of-order sections - Closer to Rust wasm-split than header-only parsing was
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4289633. Configure here.
loewenheim
left a comment
There was a problem hiding this comment.
Seems solid apart from the manual UUID parsing stuff.
There was a problem hiding this comment.
All the UUID stuff should probably be handled by the uuid7 library, which is already a dependency.
a408240 to
0b4e3b4
Compare
0b4e3b4 to
a408240
Compare
| * id, but the distinction still matters: minting a fresh id for a module that | ||
| * already has a good one would orphan every debug file uploaded against it. | ||
| */ | ||
| export function buildIdFromSections( |
There was a problem hiding this comment.
IMO this is the only worthwhile function left in this file, and it could go in binary.ts. The rest are just converting between UUIDs, bytes, and strings.
I think the UUID type should be used wherever possible, including in the output of this function, and only be converted to a string or bytes when it needs to be written somewhere.
There was a problem hiding this comment.
I'd keep the wrappers: each handles a different concern in one place, uuidToBytes turns parse failures into CLI errors, and UUID on the read path is wrong because build_id is arbitrary bytes. The other cmd i'm working on will reuse the same helpers when it reads and stamps ids.
a408240 to
0fc4d8f
Compare
0fc4d8f to
a408240
Compare
…sm-split behavior)
| continue; | ||
| } | ||
| const buildId = decodeBuildId(section.contents); | ||
| if (buildId) { |
There was a problem hiding this comment.
Bug: The check if (buildId) incorrectly evaluates to true for an empty Uint8Array, causing the tool to accept an empty build ID instead of generating a new one.
Severity: MEDIUM
Suggested Fix
Change the condition if (buildId) to if (buildId !== null) to correctly distinguish between a null value (no section found) and an empty Uint8Array (empty section found). This ensures that an empty but present build ID section will still trigger the generation of a new build ID.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/cli/src/lib/wasm/build-id.ts#L74
Potential issue: In `buildIdFromSections`, the check `if (buildId)` is used to determine
if a build ID was found. However, if a WebAssembly module's `build_id` section contains
a zero-length vector, `decodeBuildId` returns an empty `Uint8Array`. In JavaScript, an
empty `Uint8Array` is an object and therefore truthy, causing the check to pass. This
prevents the subsequent logic in `splitWasm` from generating a new random build ID when
one is missing, as the empty array is not `null`. As a result, the tool outputs an empty
string for the build ID, which can break downstream processes like symbolication.

Summary
Ports Symbolicator's
wasm-splitinto the CLI assentry wasm-split.Same flags, same behaviour, same stdout (lowercase hex build id). Drop-in for the Rust binary. Nothing removed from Symbolicator.
Notes
Validation matches
wasmbin, not a full wasm engine.We validate the module envelope (header, section ids, and section order), but we do not read or validate the contents inside each section. Those bytes are passed through unchanged. This matches Symbolicator's Rust wasm-split.
We intentionally do not use WebAssembly.validate, since it performs deeper checks than wasmbin and would reject inputs the Rust tool accepts.