Skip to content

WsgiToAsgiInstance.build_environ crashes when scope.server is present, but set to None #514

@graysonchao

Description

@graysonchao

Some ASGI servers, such as uvicorn, will sometimes pass a scope object to WsgiToAsgi where scope["server"] is set to None. This causes the app to crash when build_environ tries to access scope["server"] like a tuple (here).

However, extending the check to include that scope["server"] is not None would be an imperfect fix, because it would set SERVER_NAME and SERVER_PORT to "localhost:80" when in some cases that's not true - for example, when launching uvicorn bound to a Unix socket. This latter issue likely needs to be fixed in the server code, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions