Skip to content

Commit

Permalink
fix(asgi): Fix KeyError if transaction does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinji committed Feb 24, 2025
1 parent 189e4a9 commit 8e2e051
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sentry_sdk/integrations/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,11 @@ def event_processor(self, event, hint, asgi_scope):
event["request"] = deepcopy(request_data)

# Only set transaction name if not already set by Starlette or FastAPI (or other frameworks)
already_set = event["transaction"] != _DEFAULT_TRANSACTION_NAME and event[
"transaction_info"
].get("source") in [
already_set = event.get(
"transaction"
) != _DEFAULT_TRANSACTION_NAME and event.get("transaction_info", {}).get(
"source"
) in [
TransactionSource.COMPONENT,
TransactionSource.ROUTE,
TransactionSource.CUSTOM,
Expand Down

0 comments on commit 8e2e051

Please sign in to comment.