bug: ValueError: Chunk too big when streaming large files from pipelines #3956

Closed
opened 2025-11-11 15:43:16 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @lalanikarim on GitHub (Feb 18, 2025).

Installation Method

Kubernetes using helm charts - https://artifacthub.io/packages/helm/open-webui/open-webui
Behind Cloudflare Tunnel

Environment

  • Open WebUI Version: v0.5.14

  • Ollama (if applicable): 0.5.11 (not applicable)

  • Open WebUI Pipelines

  • Operating System: Ubuntu 22.04.5 LTS

  • Browser (if applicable): 134.0.2 (64-bit)

Confirmation:

  • I have read and followed all the instructions provided in the README.md.
  • I am on the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior:

Open WebUI handles large files correctly

Actual Behavior:

Open WebUI chat stalls and server logs have the following trace:

INFO  [open_webui.routers.openai] get_all_models()
INFO:     10.42.1.182:0 - "POST /api/chat/completions HTTP/1.1" 200 OK
INFO:     10.42.4.140:0 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200 OK
ERROR [asyncio] Task exception was never retrieved
future: <Task finished name='Task-20109' coro=<process_chat_response.<locals>.post_response_handler() done, defined at /app/backend/open_webui/utils/middleware.py:1074> exception=ValueError('Chunk too big')>
Traceback (most recent call last):
  File "/app/backend/open_webui/utils/middleware.py", line 1579, in post_response_handler
    await stream_body_handler(response)
  File "/app/backend/open_webui/utils/middleware.py", line 1416, in stream_body_handler
    async for line in response.body_iterator:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 52, in __anext__
    rv = await self.read_func()
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 352, in readline
    return await self.readuntil()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 380, in readuntil
    raise ValueError("Chunk too big")
ValueError: Chunk too big

Description

Bug Summary:
When receiving large files in content as base64 encoded strings from pipelines, Open WebUI middleware throws "ValueError: Chunk too big" exception.

Reproduction Details

Steps to Reproduce:

  1. Upload the pipeline from the following github repo: https://github.com/lalanikarim/comfy-mcp-pipeline/blob/large-file-issue/test-pipeline.py
  2. Start a new chat
  3. Select "Large File Test" from model list
  4. There are 3 image files on the same github repo: Image-208.png, Image-512.png, and Image-1024.png. type the number associated with the image file to have the pipeline download it from the repo and send the contents as image_url string with file contents as base64 encoded string. The outlet will then transform the last message and return a file object back.
  5. send "208" as the user message. You will see the Open WebUI respond with Image-208.png.
  6. send "512" or "1024" as the user message. Open WebUI will not render the files for these requests.

Logs and Screenshots

Browser Console Logs:
[Include relevant browser console logs, if applicable]

Docker Container Logs:

Open WebUI container logs

INFO  [open_webui.routers.openai] get_all_models()
INFO:     10.42.1.182:0 - "POST /api/chat/completions HTTP/1.1" 200 OK
INFO:     10.42.4.140:0 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200 OK
ERROR [asyncio] Task exception was never retrieved
future: <Task finished name='Task-20109' coro=<process_chat_response.<locals>.post_response_handler() done, defined at /app/backend/open_webui/utils/middleware.py:1074> exception=ValueError('Chunk too big')>
Traceback (most recent call last):
  File "/app/backend/open_webui/utils/middleware.py", line 1579, in post_response_handler
    await stream_body_handler(response)
  File "/app/backend/open_webui/utils/middleware.py", line 1416, in stream_body_handler
    async for line in response.body_iterator:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 52, in __anext__
    rv = await self.read_func()
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 352, in readline
    return await self.readuntil()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 380, in readuntil
    raise ValueError("Chunk too big")
ValueError: Chunk too big

Pipeline container logs

INFO:     10.42.3.252:50240 - "GET /models HTTP/1.1" 200 OK
test-pipeline
test-pipeline
INFO:     10.42.3.252:50242 - "POST /chat/completions HTTP/1.1" 200 OK
pipe:test-pipeline
https://raw.githubusercontent.com/lalanikarim/comfy-mcp-pipeline/refs/heads/large-file-issue/assets/Image-208.png
outlet:test-pipeline
switching content to file
INFO:     10.42.3.252:50244 - "POST /test-pipeline/filter/outlet HTTP/1.1" 200 OK
inlet:test-pipeline
INFO:     10.42.3.252:45780 - "POST /test-pipeline/filter/inlet HTTP/1.1" 200 OK
INFO:     10.42.3.252:45788 - "GET /models HTTP/1.1" 200 OK
test-pipeline
test-pipeline
INFO:     10.42.3.252:45804 - "POST /chat/completions HTTP/1.1" 200 OK
pipe:test-pipeline
https://raw.githubusercontent.com/lalanikarim/comfy-mcp-pipeline/refs/heads/large-file-issue/assets/Image-512.png

Screenshots/Screen Recordings (if applicable):

Image

Additional Information

From what I gather, the content size exceeds the asyncio's buffer settings something along those lines.

Note

If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!

Originally created by @lalanikarim on GitHub (Feb 18, 2025). ## Installation Method Kubernetes using helm charts - https://artifacthub.io/packages/helm/open-webui/open-webui Behind Cloudflare Tunnel ## Environment - **Open WebUI Version:** v0.5.14 - **Ollama (if applicable):** 0.5.11 (not applicable) - **Open WebUI Pipelines** - **Operating System:** Ubuntu 22.04.5 LTS - **Browser (if applicable):** 134.0.2 (64-bit) **Confirmation:** - [x] I have read and followed all the instructions provided in the README.md. - [x] I am on the latest version of both Open WebUI and Ollama. - [ ] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below. ## Expected Behavior: Open WebUI handles large files correctly ## Actual Behavior: Open WebUI chat stalls and server logs have the following trace: ```st INFO [open_webui.routers.openai] get_all_models() INFO: 10.42.1.182:0 - "POST /api/chat/completions HTTP/1.1" 200 OK INFO: 10.42.4.140:0 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200 OK ERROR [asyncio] Task exception was never retrieved future: <Task finished name='Task-20109' coro=<process_chat_response.<locals>.post_response_handler() done, defined at /app/backend/open_webui/utils/middleware.py:1074> exception=ValueError('Chunk too big')> Traceback (most recent call last): File "/app/backend/open_webui/utils/middleware.py", line 1579, in post_response_handler await stream_body_handler(response) File "/app/backend/open_webui/utils/middleware.py", line 1416, in stream_body_handler async for line in response.body_iterator: File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 52, in __anext__ rv = await self.read_func() ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 352, in readline return await self.readuntil() ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 380, in readuntil raise ValueError("Chunk too big") ValueError: Chunk too big ``` ## Description **Bug Summary:** When receiving large files in content as base64 encoded strings from pipelines, Open WebUI middleware throws "ValueError: Chunk too big" exception. ## Reproduction Details **Steps to Reproduce:** 1. Upload the pipeline from the following github repo: https://github.com/lalanikarim/comfy-mcp-pipeline/blob/large-file-issue/test-pipeline.py 2. Start a new chat 3. Select "Large File Test" from model list 4. There are 3 image files on the same github repo: Image-208.png, Image-512.png, and Image-1024.png. type the number associated with the image file to have the pipeline download it from the repo and send the contents as image_url string with file contents as base64 encoded string. The outlet will then transform the last message and return a file object back. 5. send "208" as the user message. You will see the Open WebUI respond with Image-208.png. 6. send "512" or "1024" as the user message. Open WebUI will not render the files for these requests. ## Logs and Screenshots **Browser Console Logs:** [Include relevant browser console logs, if applicable] **Docker Container Logs:** Open WebUI container logs ```st INFO [open_webui.routers.openai] get_all_models() INFO: 10.42.1.182:0 - "POST /api/chat/completions HTTP/1.1" 200 OK INFO: 10.42.4.140:0 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200 OK ERROR [asyncio] Task exception was never retrieved future: <Task finished name='Task-20109' coro=<process_chat_response.<locals>.post_response_handler() done, defined at /app/backend/open_webui/utils/middleware.py:1074> exception=ValueError('Chunk too big')> Traceback (most recent call last): File "/app/backend/open_webui/utils/middleware.py", line 1579, in post_response_handler await stream_body_handler(response) File "/app/backend/open_webui/utils/middleware.py", line 1416, in stream_body_handler async for line in response.body_iterator: File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 52, in __anext__ rv = await self.read_func() ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 352, in readline return await self.readuntil() ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 380, in readuntil raise ValueError("Chunk too big") ValueError: Chunk too big ``` Pipeline container logs ``` INFO: 10.42.3.252:50240 - "GET /models HTTP/1.1" 200 OK test-pipeline test-pipeline INFO: 10.42.3.252:50242 - "POST /chat/completions HTTP/1.1" 200 OK pipe:test-pipeline https://raw.githubusercontent.com/lalanikarim/comfy-mcp-pipeline/refs/heads/large-file-issue/assets/Image-208.png outlet:test-pipeline switching content to file INFO: 10.42.3.252:50244 - "POST /test-pipeline/filter/outlet HTTP/1.1" 200 OK inlet:test-pipeline INFO: 10.42.3.252:45780 - "POST /test-pipeline/filter/inlet HTTP/1.1" 200 OK INFO: 10.42.3.252:45788 - "GET /models HTTP/1.1" 200 OK test-pipeline test-pipeline INFO: 10.42.3.252:45804 - "POST /chat/completions HTTP/1.1" 200 OK pipe:test-pipeline https://raw.githubusercontent.com/lalanikarim/comfy-mcp-pipeline/refs/heads/large-file-issue/assets/Image-512.png ``` **Screenshots/Screen Recordings (if applicable):** ![Image](https://github.com/user-attachments/assets/966b0552-2b8d-45c5-88b9-52eddc655674) ## Additional Information From what I gather, the content size exceeds the asyncio's buffer settings something along those lines. ## Note If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!
Author
Owner

@tjbck commented on GitHub (Feb 18, 2025):

Sending base64 data directly is not a best practice, however I'd be open to PRs addressing this!

@tjbck commented on GitHub (Feb 18, 2025): Sending `base64` data directly is not a best practice, however I'd be open to PRs addressing this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#3956