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

Incompatible with latest version of Starlette (v0.18.0) #1593

Closed
TimPansino opened this issue Jan 25, 2022 · 0 comments · Fixed by #1594
Closed

Incompatible with latest version of Starlette (v0.18.0) #1593

TimPansino opened this issue Jan 25, 2022 · 0 comments · Fixed by #1594

Comments

@TimPansino
Copy link
Contributor

TimPansino commented Jan 25, 2022

Overview

The newest version of starlette gives a crash when initializing the sub_response on this line.

Specifically, setting status_code=None prevents the Response from initializing due to the code in Starlette's Response.init_headers() on this line.

Stack Trace

.tox/python-framework_strawberry-py39-strawberrylatest/lib/python3.9/site-packages/strawberry/asgi/__init__.py:45: in __call__
    await self.http_handler_class(
.tox/python-framework_strawberry-py39-strawberrylatest/lib/python3.9/site-packages/strawberry/asgi/handlers/http_handler.py:38: in handle
    sub_response = Response(
../../Packages/starlette/starlette/responses.py:50: in __init__
    self.init_headers(headers)

    def init_headers(self, headers: typing.Mapping[str, str] = None) -> None:
        if headers is None:
            raw_headers: typing.List[typing.Tuple[bytes, bytes]] = []
            populate_content_length = True
            populate_content_type = True
        else:
            raw_headers = [
                (k.lower().encode("latin-1"), v.encode("latin-1"))
                for k, v in headers.items()
            ]
            keys = [h[0] for h in raw_headers]
            populate_content_length = b"content-length" not in keys
            populate_content_type = b"content-type" not in keys
    
        body = getattr(self, "body", None)
        if (
            body is not None
            and populate_content_length
>           and not (self.status_code < 200 or self.status_code in (204, 304))
        ):
E       TypeError: '<' not supported between instances of 'NoneType' and 'int'
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

Successfully merging a pull request may close this issue.

1 participant