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: RequestFactory with empty data #1419

Closed
4 tasks
peterschutt opened this issue Mar 31, 2023 · 0 comments · Fixed by #1420
Closed
4 tasks

Bug: RequestFactory with empty data #1419

peterschutt opened this issue Mar 31, 2023 · 0 comments · Fixed by #1420
Labels
Bug 🐛 This is something that is not working as expected Triage Required 🏥 This requires triage

Comments

@peterschutt
Copy link
Contributor

Description

Accessing Request.body() on a request constructed with RequestFactory where data={} raises RuntimeError.

URL to code causing the issue

No response

MCVE

-console
(starlite-py3.8) peter@peter-Inspiron-15-5510:~/PycharmProjects/starlite$ python -m asyncio
asyncio REPL 3.8.15 (default, Oct 17 2022, 12:54:29) 
[GCC 9.4.0] on linux
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> from starlite.testing import RequestFactory
>>> await RequestFactory().post(data={}).body()
Traceback (most recent call last):
  File "/home/peter/.pyenv/versions/3.8.15/lib/python3.8/concurrent/futures/_base.py", line 444, in result
    return self.__get_result()
  File "/home/peter/.pyenv/versions/3.8.15/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "<console>", line 1, in <module>
  File "/home/peter/PycharmProjects/starlite/starlite/connection/request.py", line 147, in body
    self._body = self.scope["_body"] = b"".join([c async for c in self.stream()])  # type: ignore[typeddict-unknown-key]
  File "/home/peter/PycharmProjects/starlite/starlite/connection/request.py", line 147, in <listcomp>
    self._body = self.scope["_body"] = b"".join([c async for c in self.stream()])  # type: ignore[typeddict-unknown-key]
  File "/home/peter/PycharmProjects/starlite/starlite/connection/request.py", line 119, in stream
    while event := await self.receive():
  File "/home/peter/PycharmProjects/starlite/starlite/connection/base.py", line 40, in empty_receive
    raise RuntimeError()
RuntimeError

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

Starlite Version

main

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)
@peterschutt peterschutt added Bug 🐛 This is something that is not working as expected Triage Required 🏥 This requires triage labels Mar 31, 2023
provinzkraut added a commit that referenced this issue Mar 31, 2023
support empty body in RequestFactory
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 Triage Required 🏥 This requires triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant