Skip to content

Commit d9a5dd5

Browse files
authored
debug: Gather more context and report exceptions on signature issues (#54464)
Unsubscribe notification signatures aren't working in saas, but they do seem to work locally and in s4s. Currently difficult to determine the source causes, so trying to capture an exception here with additional context for debugging purposes.
1 parent 9c7b120 commit d9a5dd5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/sentry/utils/linksign.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django.core import signing
66
from django.urls import reverse
7+
from sentry_sdk.api import capture_exception
78

89
from sentry import options
910
from sentry.models import User
@@ -50,10 +51,15 @@ def process_signature(request, max_age=60 * 60 * 24 * 10):
5051
if not sig or sig.count(":") < 2:
5152
return None
5253

53-
signed_data = "{}|{}|{}".format(request.build_absolute_uri("/").rstrip("/"), request.path, sig)
54+
request_absolute_uri = request.build_absolute_uri("/").rstrip("/")
55+
request_path = request.path
56+
signed_data = f"{request_absolute_uri}|{request_path}|{sig}"
5457
try:
5558
data = get_signer().unsign(signed_data, max_age=max_age)
56-
except signing.BadSignature:
59+
except signing.BadSignature as e:
60+
# We should plan on removing this after debugging the current issue -- it is an 'expected' exception and not
61+
# actually exceptional.
62+
capture_exception(e)
5763
return None
5864

5965
_, signed_path, user_id = data.rsplit("|", 2)

0 commit comments

Comments
 (0)