Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

FastAPI 0.87.0 (and in particular starlette 0.21.0) broke query string parsing in TestClient (starlette 0.22.0 fixes it!) #5674

Closed
9 tasks done
andreagrandi opened this issue Nov 22, 2022 · 3 comments
Labels
question Question or problem question-migrate

Comments

@andreagrandi
Copy link

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from fastapi import FastAPI

Description

We have a test that does something like this:

now = utc_datetime()
url = client.app.url_path_for("balances")
start_date = now - timedelta(minutes=1)
start_date_param = urlencode({"start_date": start_date.isoformat()})
end_date_param = urlencode({"end_date": now.isoformat()})
response = client.get(url + f"?{start_date_param}&{end_date_param}")

With FastAPI 0.86 everything works. Starting from 0.87 (which uses starlette 0.21.0) our endpoint errors with:

{'error': {'code': 'validation_error', 'message': 'Validation Error', 'errors': [{'attribute': 'query -> start_date', 'code': 'value_error.datetime', 'message': 'invalid datetime format', 'ctx': None}, {'attribute': 'query -> end_date', 'code': 'value_error.datetime', 'message': 'invalid datetime format', 'ctx': None}]}}

If I force the installation of starlette 0.22.0 and rerun the test, everything works. This is a known bug of starlette 0.21.0 and it has been fixed in 0.22.0:

Solution

Bump starlette version in FastAPI to 0.22.0

Note

I can make this small PR with the update as soon as you confirm/acknowledge this issue.

Operating System

macOS

Operating System Details

No response

FastAPI Version

0.87.0

Python Version

3.10.0

Additional Context

No response

@andreagrandi andreagrandi added the question Question or problem label Nov 22, 2022
@TheJumpyWizard
Copy link

There's a PR up for this now actually

@slafs
Copy link
Sponsor

slafs commented Nov 22, 2022

The PR is #5659
and this issue is then, most likely, a duplicate of #5646.

@andreagrandi
Copy link
Author

Thanks everyone for the feedback. It seems a duplicate of #5646 yes and since there is already a PR to fix this, I closed the issue already. Looking forward to 0.88.0 release 🫶

@tiangolo tiangolo reopened this Feb 27, 2023
Repository owner locked and limited conversation to collaborators Feb 27, 2023
@tiangolo tiangolo converted this issue into discussion #6199 Feb 27, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Question or problem question-migrate
Projects
None yet
Development

No branches or pull requests

4 participants