Skip to content

Commit 5bb54ec

Browse files
committed
fix(asgi): fix KeyError if transaction does not exist
1 parent 189e4a9 commit 5bb54ec

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sentry_sdk/integrations/asgi.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,11 @@ def event_processor(self, event, hint, asgi_scope):
267267
event["request"] = deepcopy(request_data)
268268

269269
# Only set transaction name if not already set by Starlette or FastAPI (or other frameworks)
270-
already_set = event["transaction"] != _DEFAULT_TRANSACTION_NAME and event[
271-
"transaction_info"
272-
].get("source") in [
270+
already_set = event.get(
271+
"transaction"
272+
) != _DEFAULT_TRANSACTION_NAME and event.get("transaction_info", {}).get(
273+
"source"
274+
) in [
273275
TransactionSource.COMPONENT,
274276
TransactionSource.ROUTE,
275277
TransactionSource.CUSTOM,

0 commit comments

Comments
 (0)