sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

setTag recording inconsistent values despite setting the same value in code

Open lukemun opened this issue 9 months ago • 10 comments

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

Using the React Native SDK to Sentry.setTag("XXX", true) is producing true and True values in the Sentry UI. While we have been able to work around this, it's concerning the data is not accurate in Sentry.

Only seen it happen for "boolean" values.

Expected Result

Value is always true.

Actual Result

Image

It seems to happen sporadically and just in the Errors dataset AFAIK.

Image

Customer Specific Details in Case: https://www.notion.so/sentry/1c78b10e4b5d80f89aa9c802f6ad74fc

Product Area

Processing

Link

No response

DSN

No response

Version

No response

lukemun avatar Mar 31 '25 20:03 lukemun

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] avatar Mar 31 '25 20:03 getsantry[bot]

Routing to @getsentry/product-owners-processing for triage ⏲️

getsantry[bot] avatar Apr 01 '25 22:04 getsantry[bot]

@krystofwoldrich Is there a chance this is due to the SDK in any way? Or are we fairly certain this stems from the ingestion?

tobias-wilfert avatar Apr 03 '25 08:04 tobias-wilfert

Thank you for the message and the ping @tobias-wilfert.

It might be a difference between JS procession of the event in the SDK when using Expo Go/Expo Dev Client and when using Release Build.

The example on the linked notion page shows an issue with a tag equal True 99% and true 1%, which supports the dev vs release suspicion.

I'm looking into it at the moment.

krystofwoldrich avatar Apr 10 '25 13:04 krystofwoldrich

I've tried to reproduce the issue, and both in dev and release, the sdk is sending json with {"test-true": true}, but I see True in the Sentry UI.

Example Issue

@tobias-wilfert Could there be some nondeterministic behavior during processing?

krystofwoldrich avatar Apr 10 '25 13:04 krystofwoldrich

Asked the team and it converting true -> "True" is the intended behaviour here. Would be cool if we could somehow managed to reproduce the true -> "true".

Although I am thinking now that this might probably be a issue in Relay since we have 2 different ways to convert which are used in different contexts: https://github.com/getsentry/relay/blob/4e752d81df91a13b0f944d4859da4099de6d936d/relay-event-schema/src/protocol/types.rs#L680-L682 (True) https://github.com/getsentry/relay/blob/4e752d81df91a13b0f944d4859da4099de6d936d/relay-event-schema/src/protocol/types.rs#L751-L753 (true)

So not sure why we hit the one or the other for the same tag but maybe it has something to do with that 🤔 but if the SDK always sends a boolean than I think it is safe to assume that it is not the culprit.

tobias-wilfert avatar Apr 10 '25 13:04 tobias-wilfert

I've found the culprit, it's related to how we synchronize tags between native and JS.

See the nativeTags vs event.tags.

Image

I'll move this issue to the RN SDK repository.

krystofwoldrich avatar Apr 10 '25 14:04 krystofwoldrich

@krystofwoldrich Thanks so much great investigation work 🙏🏻

tobias-wilfert avatar Apr 10 '25 14:04 tobias-wilfert

The native SDKs, sentry-cocoa and sentry-android, only accept string as a tag type, the RN SDK converts the tags to a string when passing them to the native SDKs.

krystofwoldrich avatar Apr 10 '25 14:04 krystofwoldrich

We will fix this in the RN SDK by stringifying all tags to align with the native SDK.

So the RN SDK will convert true -> 'True' and the same for the other primitives supported by the JS interface.

This has a side effect for native events, which now send true -> 'true', but after the change, they will send true -> 'True', which aligns with the RN/JS layer but could break users queries in Sentry.

krystofwoldrich avatar Apr 11 '25 18:04 krystofwoldrich

This issue will be fixed on the next version of Sentry React Native V7

lucas-zimerman avatar Jul 08 '25 21:07 lucas-zimerman