Skip to content

Commit 56ec01c

Browse files
More defensive check
1 parent 38ef8a7 commit 56ec01c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sentry_sdk/integrations/fastapi.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,12 @@ async def _sentry_app(*args, **kwargs):
111111
extractor = StarletteRequestExtractor(request)
112112

113113
request_scope = request.scope
114-
is_fastapi_mcp = (
115-
request_scope.get("endpoint")
116-
and "FastApiMCP" in request_scope["endpoint"].__qualname__
117-
)
118-
info = await extractor.extract_request_info(read_body=not is_fastapi_mcp)
114+
if "endpoint" in request_scope:
115+
qualname = getattr(request_scope["endpoint"], "__qualname__", None)
116+
read_body = qualname is None or "FastApiMCP" not in qualname
117+
info = await extractor.extract_request_info(read_body)
118+
else:
119+
info = await extractor.extract_request_info(True)
119120

120121
def _make_request_event_processor(req, integration):
121122
# type: (Any, Any) -> Callable[[Event, Dict[str, Any]], Event]

0 commit comments

Comments
 (0)