Skip to content

Commit

Permalink
Fix rust sentry errors having double quotes (#9732)
Browse files Browse the repository at this point in the history
* some progress

* map the valus to strings before passing to sentry to avoid double quoted tags

* remove panic for testing

---------

Co-authored-by: ngrujic <ngrujic@atlassian.com>
Co-authored-by: Marcin Szczepanski <mszczepanski@atlassian.com>
  • Loading branch information
3 people committed May 23, 2024
1 parent f833a24 commit 89a69f5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/node-bindings/src/init_sentry/sentry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ static SENTRY_GUARD: Lazy<Arc<Mutex<Option<ClientInitGuard>>>> =
Lazy::new(|| Arc::new(Mutex::new(None)));
const TIMEOUT: Duration = Duration::from_secs(2);

fn value_to_string(value: &serde_json::Value) -> String {
match value {
serde_json::Value::String(inner) => inner.clone(),
other => other.to_string(),
}
}

#[napi]
fn init_sentry() -> Result<(), Status> {
if std::env::var("PARCEL_ENABLE_SENTRY").is_err() {
Expand Down Expand Up @@ -51,6 +58,11 @@ fn init_sentry() -> Result<(), Status> {
..Default::default()
};

let sentry_tags: HashMap<String, String> = sentry_tags
.iter()
.map(|(k, v)| (k.clone(), value_to_string(v)))
.collect::<HashMap<String, String>>();

if let Some(release) = sentry_tags.get("release") {
sentry_client_options.release = Some(release.to_string().into());
}
Expand Down

0 comments on commit 89a69f5

Please sign in to comment.