Skip to content

Python ASGI documentation causes errors in FastAPI #5272

@minboost

Description

@minboost

Core or SDK?

Platform/SDK

Which part? Which one?

https://docs.sentry.io/platforms/python/guides/asgi/

Description

Integrating with FastAPI with the following line throws various errors, depending on what is implemented

asgi_app = SentryAsgiMiddleware(asgi_app)

Some errors could include:

@app.middleware("http")
AttributeError: 'SentryAsgiMiddleware' object has no attribute 'middleware'
@app.on_event('shutdown')
AttributeError: 'SentryAsgiMiddleware' object has no attribute 'on_event'

Integrating the middleware as described in the FastAPI docs fixes the problem:

asgi_app.add_middleware(SentryAsgiMiddleware)

Suggested Solution

Update the documents with an example for FastAPI and/or a note that some ASGI middleware must be installed differently than shown in the example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions