From c727fe467d190996355f253da56f2e897ce1c56d Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Wed, 6 Nov 2024 16:34:11 +0100 Subject: [PATCH 1/4] feat(js): Read debug IDs from debugId field Companion PR to https://github.com/getsentry/rust-sourcemap/pull/97. This adjusts `discover_sourcemap_embedded_debug_id` so that it finds debug IDs at both `"debug_id"` and `"debugId"`. --- symbolic-debuginfo/src/js.rs | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/symbolic-debuginfo/src/js.rs b/symbolic-debuginfo/src/js.rs index d47c8897..3356a702 100644 --- a/symbolic-debuginfo/src/js.rs +++ b/symbolic-debuginfo/src/js.rs @@ -29,9 +29,12 @@ pub fn discover_sourcemaps_location(contents: &str) -> Option<&str> { } /// Quickly reads the embedded `debug_id` key from a source map. +/// +/// Both `debug_id` and `debugId` are supported as field names. pub fn discover_sourcemap_embedded_debug_id(contents: &str) -> Option { #[derive(Deserialize)] struct DebugIdInSourceMap { + #[serde(alias = "debugId")] debug_id: Option, } @@ -49,3 +52,42 @@ pub fn discover_debug_id(contents: &str) -> Option { } None } + +#[cfg(test)] +mod tests { + use debugid::DebugId; + + use crate::js::discover_sourcemap_embedded_debug_id; + + #[test] + fn test_debugid_snake_case() { + let input = r#"{ + "version":3, + "sources":["coolstuff.js"], + "names":["x","alert"], + "mappings":"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM", + "debug_id":"00000000-0000-0000-0000-000000000000" + }"#; + + assert_eq!( + discover_sourcemap_embedded_debug_id(input), + Some(DebugId::default()) + ); + } + + #[test] + fn test_debugid_camel_case() { + let input = r#"{ + "version":3, + "sources":["coolstuff.js"], + "names":["x","alert"], + "mappings":"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM", + "debugId":"00000000-0000-0000-0000-000000000000" + }"#; + + assert_eq!( + discover_sourcemap_embedded_debug_id(input), + Some(DebugId::default()) + ); + } +} From 012b5550416a1d1502ab26fc0431651e39333b9e Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Wed, 6 Nov 2024 16:38:03 +0100 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd376d1..3c98f53d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +# Unreleased + +**Features**: +- feat(js): Sourcemap debug IDs can now be read from the `"debugId"` field in addition to + `"debug_id"` ([#870](https://github.com/getsentry/symbolic/pull/870)). + ## 12.12.0 ### Various fixes & improvements From 2ed7ff64cc31f9491dad3c7881f999d3fc862bca Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Wed, 6 Nov 2024 17:14:19 +0100 Subject: [PATCH 3/4] changelog again --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c98f53d..5d05acc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,6 @@ ## 12.12.0 -### Various fixes & improvements - **Fixes** - Unship "Support for DWARFv5 embedded source code extension ([#849](https://github.com/getsentry/symbolic/pull/849))". Unfortunately the check for whether an elf file contains embedded sources is prohibitively expensive in terms of memory. From 74170dc038f542f2aad3773a2131c34c37329c89 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Thu, 7 Nov 2024 11:16:59 +0100 Subject: [PATCH 4/4] Fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d05acc7..0d6a1492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -# Unreleased +## Unreleased **Features**: - feat(js): Sourcemap debug IDs can now be read from the `"debugId"` field in addition to