Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(js): Prefer "debug_id" #878

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

**Fixes**
- js: Prefer `"debug_id"` for sourcemap debug IDs. ([#878](https://github.com/getsentry/symbolic/pull/878)).

## 12.12.2

**Fixes**
Expand Down
10 changes: 5 additions & 5 deletions symbolic-debuginfo/src/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ pub fn discover_sourcemaps_location(contents: &str) -> Option<&str> {
/// Quickly reads the embedded `debug_id` key from a source map.
///
/// Both `debugId` and `debug_id` are supported as field names. If both
/// are set, the former takes precedence.
/// are set, the latter takes precedence.
pub fn discover_sourcemap_embedded_debug_id(contents: &str) -> Option<DebugId> {
// Deserialize from `"debugId"` or `"debug_id"`,
// preferring the former.
// preferring the latter.
#[derive(Deserialize)]
struct DebugIdInSourceMap {
#[serde(rename = "debugId")]
Expand All @@ -45,7 +45,7 @@ pub fn discover_sourcemap_embedded_debug_id(contents: &str) -> Option<DebugId> {

serde_json::from_str(contents)
.ok()
.and_then(|x: DebugIdInSourceMap| x.debug_id_new.or(x.debug_id_old))
.and_then(|x: DebugIdInSourceMap| x.debug_id_old.or(x.debug_id_new))
}

/// Parses a `debugId` comment in a file to discover a sourcemap's debug ID.
Expand Down Expand Up @@ -103,8 +103,8 @@ mod tests {
"sources":["coolstuff.js"],
"names":["x","alert"],
"mappings":"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM",
"debugId":"00000000-0000-0000-0000-000000000000",
"debug_id":"11111111-1111-1111-1111-111111111111"
"debug_id":"00000000-0000-0000-0000-000000000000",
"debugId":"11111111-1111-1111-1111-111111111111"
}"#;

assert_eq!(
Expand Down
Loading