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

Empty file Content-type error #155

Open
IgnacioHeredia opened this issue Apr 30, 2024 · 1 comment
Open

Empty file Content-type error #155

IgnacioHeredia opened this issue Apr 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@IgnacioHeredia
Copy link
Collaborator

IgnacioHeredia commented Apr 30, 2024

When a module has an predict arg which is a file (eg. image), but the arg is not required, deepaas fails to run:

        "demo-image": fields.Field(
            required=False,
            type="file",
            location="form",
            description="image",  # description needed to be parsed by UI
        ),

Seems to be related to the Content-type header in the aiohttp call. I opened a branch in the demo-app to test this: empty-file-form.

This issue was originally raised by @emvollmer (Nov. 2023)

Error logs

2024-04-30 15:46:17.946 162826 ERROR aiohttp.server [-] Error handling request: ValueError: boundary missed for Content-Type: multipart/form-data
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server Traceback (most recent call last):
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     resp = await request_handler(request)
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/aiohttp/web_app.py", line 504, in _handle
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     resp = await handler(request)
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 117, in impl
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     return await handler(request)
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 108, in impl
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     return await handler(request)
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 117, in impl
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     return await handler(request)
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/ignacio/projects/deephdc/deepaas/deepaas/api/v2/predict.py", line 66, in post
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     args = await aiohttpparser.parser.parse(handler_args, request)
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/webargs/asyncparser.py", line 87, in parse
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     parsed = await self._parse_request(
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/webargs/asyncparser.py", line 59, in _parse_request
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     parsed_value = await self.parse_arg(
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/webargs/asyncparser.py", line 206, in parse_arg
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     value = await self._get_value(name, field, req=req, location=location)
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/webargs/asyncparser.py", line 217, in _get_value
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     value = await function(req, name, argobj)
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/webargs/aiohttpparser.py", line 89, in parse_form
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     self._cache["post"] = await req.post()
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/aiohttp/web_request.py", line 689, in post
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     multipart = await self.multipart()
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/aiohttp/web_request.py", line 667, in multipart
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     return MultipartReader(self._headers, self._payload)
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/aiohttp/multipart.py", line 537, in __init__
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     self._boundary = ("--" + self._get_boundary()).encode()
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server   File "/home/iheredia/anaconda3/lib/python3.8/site-packages/aiohttp/multipart.py", line 636, in _get_boundary
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server     raise ValueError(
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server ValueError: boundary missed for Content-Type: multipart/form-data
2024-04-30 15:46:17.946 162826 ERROR aiohttp.server 
2024-04-30 15:46:17.948 162826 INFO aiohttp.access [-] 127.0.0.1 [30/Apr/2024:13:46:17 +0000] "POST /v2/models/ai4os_demo_app/predict/?demo-str=some-string&demo-str-choice=choice2&demo-int=1&demo-int-range=50&demo-float=0.1&demo-bool=true&demo-dict=%7B%22a%22%3A%200%2C%20%22b%22%3A%201%7D&demo-list-of-floats=0.1&demo-list-of-floats=0.2&demo-list-of-floats=0.3 HTTP/1.1" 500 244 "http://0.0.0.0:5000/api" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"

@IgnacioHeredia IgnacioHeredia added the bug Something isn't working label Apr 30, 2024
@IgnacioHeredia
Copy link
Collaborator Author

Tried to inspect this but at that point args are already parsed by aiohttp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant