55from copy import deepcopy
66from datetime import datetime , timedelta , timezone
77from os import environ
8+ from urllib .parse import urlencode
89
910import sentry_sdk
1011from sentry_sdk .consts import OP
@@ -336,7 +337,7 @@ def event_processor(sentry_event, hint, start_time=start_time):
336337 request ["url" ] = _get_url (aws_event , aws_context )
337338
338339 if "queryStringParameters" in aws_event :
339- request ["query_string" ] = aws_event ["queryStringParameters" ]
340+ request ["query_string" ] = urlencode ( aws_event ["queryStringParameters" ])
340341
341342 if "headers" in aws_event :
342343 request ["headers" ] = _filter_headers (aws_event ["headers" ])
@@ -483,7 +484,10 @@ def _prepopulate_attributes(aws_event, aws_context):
483484
484485 for prop , attr in EVENT_TO_ATTRIBUTES .items ():
485486 if aws_event .get (prop ) is not None :
486- attributes [attr ] = aws_event [prop ]
487+ if prop == "queryStringParameters" :
488+ attributes [attr ] = urlencode (aws_event [prop ])
489+ else :
490+ attributes [attr ] = aws_event [prop ]
487491
488492 for prop , attr in CONTEXT_TO_ATTRIBUTES .items ():
489493 if getattr (aws_context , prop , None ) is not None :
@@ -492,7 +496,7 @@ def _prepopulate_attributes(aws_event, aws_context):
492496 url = _get_url (aws_event , aws_context )
493497 if url :
494498 if aws_event .get ("queryStringParameters" ):
495- url += f"?{ aws_event ['queryStringParameters' ]} "
499+ url += f"?{ urlencode ( aws_event ['queryStringParameters' ]) } "
496500 attributes ["url.full" ] = url
497501
498502 headers = {}
0 commit comments