Skip to content

Commit 5d85f32

Browse files
committed
Some fixes
1 parent d4e8d47 commit 5d85f32

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

sentry_sdk/integrations/aws_lambda.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from copy import deepcopy
66
from datetime import datetime, timedelta, timezone
77
from os import environ
8+
from urllib.parse import urlencode
89

910
import sentry_sdk
1011
from 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 = {}

tests/integrations/aws_lambda/test_aws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def test_handler(event, context):
646646
)
647647
)
648648

649-
payload = b'{"httpMethod": "GET", "path": "/sit/stay/rollover", "queryStringParameters": "repeat=twice", "headers": {"Host": "x.io", "X-Forwarded-Proto": "http", "Custom-Header": "Custom Value"}}'
649+
payload = b'{"httpMethod": "GET", "path": "/sit/stay/rollover", "queryStringParameters": {"repeat": "twice"}, "headers": {"Host": "x.io", "X-Forwarded-Proto": "http", "Custom-Header": "Custom Value"}}'
650650

651651
_, response = run_lambda_function(
652652
code=function_code,

0 commit comments

Comments
 (0)