Browse Source

bug(replays): Add type coercion for weakly-typed data key (#52519)

https://sentry.sentry.io/issues/4213442978
Colton Allen 1 year ago
parent
commit
a7684660a7
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/sentry/replays/usecases/ingest/dom_index.py

+ 7 - 0
src/sentry/replays/usecases/ingest/dom_index.py

@@ -187,6 +187,13 @@ def get_user_actions(
             if event["data"].get("payload", {}).get("op") in ("resource.fetch", "resource.xhr"):
                 event_payload_data = event["data"]["payload"]["data"]
 
+                # The data key is sometimes submitted as an string. If any type other than a
+                # dictionary is provided default the value to an empty dict.
+                #
+                # TODO: Refactor this area in a later release.
+                if not isinstance(event_payload_data, dict):
+                    event_payload_data = {}
+
                 # these first two cover SDKs 7.44 and 7.45
                 if event_payload_data.get("requestBodySize"):
                     metrics.timing(