Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airbrake Starlette middleware throws error when running behind a reverse proxy #268

Open
pouellet opened this issue Aug 17, 2023 · 0 comments

Comments

@pouellet
Copy link

The Airbrake Starlette middleware makes the assumption that the request client will always be set:

ctx["userAddr"] = request.client.host

but Starlette defines the field as optional:

    @property
    def client(self) -> typing.Optional[Address]:
        # client is a 2 item tuple of (host, port), None or missing
        host_port = self.scope.get("client")
        if host_port is not None:
            return Address(*host_port)
        return None

When running FastAPI behind a remote proxy (Nginx) that is not configured to forward headers, the client will resolve to None, which cause the middleware to throw an error when trying to access request.client.host as it attempts to notify about an unhandled error.

@pouellet pouellet changed the title Airbrake Starlette middleware throws error when running being a reverse proxy Airbrake Starlette middleware throws error when running behind a reverse proxy Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant