mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-15 21:19:39 -05:00
[PR #24837] [CLOSED] fix(images): accept non-standard Content-Type in image generation responses #115193
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/24837
Author: @first-it-consulting
Created: 5/17/2026
Status: ❌ Closed
Base:
main← Head:fix/image-generation-aiohttp-content-type-ndjson📝 Commits (1)
e0750fefix(images): pass content_type=None to r.json() to accept non-standard MIME types📊 Changes
1 file changed (+5 additions, -5 deletions)
View changed files
📝
backend/open_webui/routers/images.py(+5 -5)📄 Description
Summary
aiohttp'sClientResponse.json()validates theContent-Typeheader againstapplication/jsonby default and raisesContentTypeErrorfor any other value. This silently breaks image generation for users whose backend returns a different but valid content type.The most common case: Ollama's OpenAI-compatible
/v1/images/generationsendpoint returnsContent-Type: application/x-ndjson(chunked streaming header) even though the response body is a single, complete JSON object. Every image generation request via Ollama fails with:The same issue can affect any other backend that returns valid JSON with a non-standard MIME type (e.g.
text/plain,application/octet-stream).Root Cause
aiohttp.ClientResponse.json()accepts acontent_typeparameter that defaults to"application/json". When the server returns any other MIME type, aiohttp raisesContentTypeErrorafter successfully reading the response body — the JSON is already there, it just never gets parsed.Fix
Pass
content_type=Noneto everyr.json()call that handles an image generation or editing response. This is the documented aiohttp pattern for skipping the content-type check while keeping all other parsing behaviour identical.Five call sites are affected:
image_generations(openai, gemini, automatic1111 engines) andimage_edits(openai, gemini engines).Testing
Verified against Ollama v0.21.2 (
/v1/images/generations) with modelx/flux2-klein:latest:ContentTypeErrorraised immediately after generation completesb64_jsonimage returned as expectedThe change is backwards-compatible — providers returning
application/jsonare unaffected.Related Issues
Content-Type: application/x-ndjson🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.