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

Bug: TypeError: parse_url_encoded_dict() got some positional-only arguments passed as keyword arguments: 'qs' and 'parse_numbers' #2020

Closed
1 of 4 tasks
euri10 opened this issue Jul 20, 2023 · 7 comments · Fixed by #2022
Labels
Bug 🐛 This is something that is not working as expected Great MCVE This is a great example of a great MCVE Upstream This is due to or tracking an upstream issue

Comments

@euri10
Copy link
Contributor

euri10 commented Jul 20, 2023

Description

New litestar install

❯ poetry add git+https://github.com/litestar-org/litestar.git

Updating dependencies
Resolving dependencies... (1.2s)

Package operations: 7 installs, 0 updates, 0 removals

  • Installing python-dateutil (2.8.2)
  • Installing faker (19.1.0)
  • Installing fast-query-parsers (1.0.1)
  • Installing msgspec (0.17.0)
  • Installing multidict (6.0.4)
  • Installing polyfactory (2.6.2)
  • Installing litestar (2.0.0beta2 dc8790e)

leads to this error filling the form below:

Traceback (most recent call last):
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/middleware/exceptions/middleware.py", line 157, in __call__
    await self.app(scope, receive, send)
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/routes/http.py", line 77, in handle
    response = await self._get_response_for_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/routes/http.py", line 129, in _get_response_for_request
    response = await self._call_handler_function(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/routes/http.py", line 158, in _call_handler_function
    response_data, cleanup_group = await self._get_response_data(
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/routes/http.py", line 182, in _get_response_data
    kwargs["data"] = await kwargs["data"]
                     ^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/_kwargs/extractors.py", line 363, in extract_url_encoded_extractor
    else parse_url_encoded_form_data(await connection.body())
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/_parsers.py", line 24, in parse_url_encoded_form_data
    return parse_url_encoded_dict(qs=encoded_data, parse_numbers=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: parse_url_encoded_dict() got some positional-only arguments passed as keyword arguments: 'qs' and 'parse_numbers'
Traceback (most recent call last):
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/middleware/exceptions/middleware.py", line 157, in __call__
    await self.app(scope, receive, send)
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/routes/http.py", line 77, in handle
    response = await self._get_response_for_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/routes/http.py", line 129, in _get_response_for_request
    response = await self._call_handler_function(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/routes/http.py", line 158, in _call_handler_function
    response_data, cleanup_group = await self._get_response_data(
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/routes/http.py", line 182, in _get_response_data
    kwargs["data"] = await kwargs["data"]
                     ^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/_kwargs/extractors.py", line 363, in extract_url_encoded_extractor
    else parse_url_encoded_form_data(await connection.body())
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lotso/.cache/pypoetry/virtualenvs/abdul-5gvWwsxX-py3.11/lib/python3.11/site-packages/litestar/_parsers.py", line 24, in parse_url_encoded_form_data
    return parse_url_encoded_dict(qs=encoded_data, parse_numbers=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: parse_url_encoded_dict() got some positional-only arguments passed as keyword arguments: 'qs' and 'parse_numbers'
INFO:     127.0.0.1:51104 - "POST /auth/login HTTP/1.1" 500 Internal Server Error

URL to code causing the issue

No response

MCVE

@dataclass
class LoginFormData:
    username: str
    password: str
    captcha: str


@post("/login", name="login_post")
async def login_post(
    request: Request,
    conn: BuildPgConnection,
    app_settings: AppSettings,
    data: Annotated[LoginFormData, Body(media_type=RequestEncodingType.URL_ENCODED)],
) -> Template:
    try:

Steps to reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Litestar Version

• Installing litestar (2.0.0beta2 dc8790e)

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Funding

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@euri10 euri10 added Bug 🐛 This is something that is not working as expected Triage Required 🏥 This requires triage labels Jul 20, 2023
@provinzkraut provinzkraut removed the Triage Required 🏥 This requires triage label Jul 20, 2023
@provinzkraut
Copy link
Member

I believe this is related to a recent change in fast-query-parsers. @Goldziher?

Not sure why this hasn't been caught in our tests though.

@Goldziher
Copy link
Contributor

Hmm yes, seems that maturin is positional only.

Can you remove parse_numbers= and keep the args?

@provinzkraut
Copy link
Member

Hmm yes, seems that maturin is positional only.

It does support it. I have a fix read to go for fast-query-parsers. PR incoming.

@provinzkraut provinzkraut added the Great MCVE This is a great example of a great MCVE label Jul 20, 2023
@euri10

This comment was marked as off-topic.

@provinzkraut
Copy link
Member

provinzkraut commented Jul 20, 2023

This should resolve it: litestar-org/fast-query-parsers#18 by allowing positional as well as keyword arguments.

@provinzkraut

This comment was marked as off-topic.

@provinzkraut provinzkraut added the Upstream This is due to or tracking an upstream issue label Jul 20, 2023
@euri10

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 This is something that is not working as expected Great MCVE This is a great example of a great MCVE Upstream This is due to or tracking an upstream issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants