From f74fcd577fee4a73ddfe3832e95c23f028c471ee Mon Sep 17 00:00:00 2001 From: Dan Sahagian <45240763+dansahagian@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:47:13 -0700 Subject: [PATCH] Add guarding clauses to the sentry filter --- fbsurvivor/settings.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fbsurvivor/settings.py b/fbsurvivor/settings.py index cdda8b3..11631fb 100644 --- a/fbsurvivor/settings.py +++ b/fbsurvivor/settings.py @@ -178,14 +178,20 @@ def before_send(event, hint): def filter_transactions(event, hint): - url_string = event["request"]["url"] - parsed_url = urlparse(url_string) + request = event.get("request") + if not request: + return None + + url = request.get("url") + if not url: + return None + parsed_url = urlparse(url) base_url = parsed_url.path[1:].split("/")[0] + if base_url in BASE_URLS: return event - else: - return None + return None sentry_sdk.init(