Skip to content

Commit 38121a2

Browse files
committed
gracefully handle decoding errors by replacing malformed data with a replacement marker
1 parent c6f834d commit 38121a2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

sentry_sdk/integrations/gcp.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def sentry_func(
102102

103103
if should_send_default_pii() and hasattr(gcp_event, "query_string"):
104104
additional_attributes["url.query"] = gcp_event.query_string.decode(
105-
"utf-8"
105+
"utf-8", errors="replace"
106106
)
107107

108108
sampling_context = {
@@ -221,7 +221,9 @@ def event_processor(event: "Event", hint: "Hint") -> "Optional[Event]":
221221
request["method"] = gcp_event.method
222222

223223
if hasattr(gcp_event, "query_string"):
224-
request["query_string"] = gcp_event.query_string.decode("utf-8")
224+
request["query_string"] = gcp_event.query_string.decode(
225+
"utf-8", errors="replace"
226+
)
225227

226228
if hasattr(gcp_event, "headers"):
227229
request["headers"] = _filter_headers(gcp_event.headers)

0 commit comments

Comments
 (0)