question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

starlette >v0.18 requires status_code on Response init

See original GitHub issue

Example Code

https://github.com/tiangolo/fastapi/blob/master/fastapi/dependencies/utils.py

line 465
    response = response or Response(
        content=None,
        status_code=None,  # type: ignore
        headers=None,  # type: ignore # in Starlette
        media_type=None,  # type: ignore # in Starlette
        background=None,  # type: ignore # in Starlette
    )

the above fails as https://github.com/encode/starlette/blob/master/starlette/responses.py requires status_code to be INT

line 74
        if (
            body is not None
            and populate_content_length
            and not (self.status_code < 200 or self.status_code in (204, 304))
        ):

FastAPI Version

0.75.1

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
deJagerFcommented, Apr 22, 2022

Greetings

I used pip to install FastAPI, (with all optional dependencies) then later I did an update to all packages. That is when I noticed that my application was failing. I then did a reinstall of FastAPI and that is when I noticed the downgrade. I checked the home page but did not see the requirement, it was only when I searched git that I saw the post and the reply with the requirement

That is why I made the suggestion that it be listed on the homepage

Hope this helps

Regards

On Fri, 22 Apr 2022, 15:56 Jordan Gould, @.***> wrote:

The projects dependencies are listed in the pyproject.toml.

Are you not using a vituralenv ? or perhaps listing Starlette along with FastAPI as a dependency?

— Reply to this email directly, view it on GitHub https://github.com/tiangolo/fastapi/issues/4800#issuecomment-1106542501, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYI5DM27RPDW4DL7POQMW3VGKVYFANCNFSM5TRCURZQ . You are receiving this because you commented.Message ID: @.***>

– This message and attachments are subject to a disclaimer.

Please refer to  http://upnet.up.ac.za/services/it/documentation/docs/004167.pdf http://upnet.up.ac.za/services/it/documentation/docs/004167.pdf for full details.

1reaction
raphaelauvcommented, May 6, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Responses
Responses. Starlette includes a few response classes that handle sending back the appropriate ASGI messages on the send channel.
Read more >
starlette
Starlette is a small library for working with ASGI. It gives you Request and Response classes, websocket support, routing, static files support, ...
Read more >
Response Status Code - FastAPI
You could also use from starlette import status . FastAPI provides the same starlette.status as fastapi.status just as a convenience for you, the...
Read more >
python - FastAPI middleware peeking into responses
from starlette.middleware.base import BaseHTTPMiddleware from ... logger.info(f'Status code: {response.status_code}') body = b"" async for ...
Read more >
init(url:statusCode:httpVersion:headerFields:)
Initializes an HTTP URL response object with a status code, protocol version, and response headers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found