You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Event breadcrumbs have incompatible types between Python and JS SDKs #1536
Background: I use sentry_sdk in Python running in the browser with Pyodide to collect a serialised Sentry event about a Python exception without actually sending it, because Python code for sending network requests doesn't work in the browser. The code for that is here: https://github.com/alexmojaki/futurecoder/blob/e09f016bd69f893d3eb81e1a4bfa804953aedb4e/core/utils.py#L205-L225 . The event is returned to JS which sends it to the server using Sentry.captureEvent. I'm @sentry/react, and it and all its dependencies like @sentry/browser are on version 7.8.1.
In summary:
In Python, use sentry_sdk.init() to set a custom transport to intercept events.
Then sentry_sdk.capture_exception() to collect an event, but don't send it.
Pass the captured event to Sentry.captureEvent() in JS.
Expected Result
The event is captured successfully and can be viewed on sentry.io. This has in fact been working great for a while, and the UI shows me info from both the JS and Python SDKs in one event.
Actual Result
Sentry.captureEvent() in JS runs into a TypeError: (e.breadcrumbs || []) is not iterable, which itself actually gets captured by Sentry and sent instead:
The problem is that in the Python event, breadcrumbs is a dict with a key values mapping to a list. But JS expects breadcrumbs to just be the list (array) rather than a dict (object). If I set event.breadcrumbs = event.breadcrumbs.values in JS, then everything goes back to working perfectly. However this doesn't mean much since in this case event.breadcrumbs is just {values: []}. I don't know if there are sometimes keys other than values, or if the lists themselves are also sometimes incompatible between the SDKs.
I don't know to what extent the different SDKs are meant to have compatible schema, but it seems like it's been working well so far and it'd be a pity to lose that. Also, I don't know if this issue belongs here or in a JS repo.
hey @alexmojaki this is a really unconventional use case, but bonus points for creativity! I'm surprised the rest of the SDK works at all since we never tested in webassembly before. ^^
I don't know to what extent the different SDKs are meant to have compatible schema, but it seems like it's been working well so far and it'd be a pity to lose that. Also, I don't know if this issue belongs here or in a JS repo.
The exception attribute should be an object with the attribute values containing a list of one or more values that are objects in the format described below. Alternatively, the exception attribute may be a flat list of objects in the format below.
Unfortunately, this really counts as an unsupported use case so you'll just have to deal with the inconsistencies on your end, sorry! If you need me to confirm something about the schema, you can ask me here again, but I'll close this issue and move it to a discussion.
Activity
sl0thentr0py commentedon Aug 3, 2022
hey @alexmojaki this is a really unconventional use case, but bonus points for creativity! I'm surprised the rest of the SDK works at all since we never tested in webassembly before. ^^
Yes, there might be some inconsistencies between SDKs in this regard, because our event schema allows both a direct list of objects or nested under
valuesas noted forexceptionhere. The same holds forbreadcrumbs.Unfortunately, this really counts as an unsupported use case so you'll just have to deal with the inconsistencies on your end, sorry! If you need me to confirm something about the schema, you can ask me here again, but I'll close this issue and move it to a discussion.