BentoML icon indicating copy to clipboard operation
BentoML copied to clipboard

bug: aiohttp.client_exceptions.ClientResponseError "Header value is too long"

Open mqk opened this issue 6 months ago • 0 comments

Describe the bug

When making a bento API request with a large payload (e.g. a JSON key-value dict with ~200 elements), I get the following error:

aiohttp.client_exceptions.ClientResponseError: 400, message='Got more than 8190 bytes (16176) when reading Header value is too long.', url=URL('http://euphoria-runner-21d5073e4bf1642829536b30741d65e1:3000/')

This is a result of the headers field that is passed into the aiohttp request (here) being too large. The headers dict has an element named Payload-Meta, whose value contains (what I assume is) a pickle of the payload (pickle_bytes_str). That can easily make the headers field larger than 8190 bytes, which is the default limit of the aiohttp.ClientSession.

The fix is relatively easy: we can just specify a larger value of max_field_size when creating self._client (here). I suggest a value of 4 times the default (so 32,760). I've tested this locally and works for me.

I'm happy to submit a PR with this fix, if that sounds appealing to you all.

To reproduce

No response

Expected behavior

No response

Environment

bentoml: 1.1.10 python: 3.11.5 platform: both x86_64 and arm64

mqk avatar Dec 19 '23 03:12 mqk