fix(images): pass content_type=None to r.json() to accept non-standard MIME types (#24838)

aiohttp's ClientResponse.json() validates the Content-Type header against
'application/json' by default and raises ContentTypeError for any other
value — including 'application/x-ndjson', which Ollama returns for its
OpenAI-compatible /v1/images/generations endpoint.

Pass content_type=None to skip this check while keeping all other parsing
behaviour unchanged.  The fix covers image generation (openai, gemini,
automatic1111 engines) and image editing (openai, gemini engines).
This commit is contained in:
HW
2026-06-01 19:33:24 +02:00
committed by GitHub
parent 936d5f2676
commit bddadafa07

View File

@@ -626,7 +626,7 @@ async def image_generations(
ssl=AIOHTTP_CLIENT_SESSION_SSL,
) as r:
r.raise_for_status()
res = await r.json()
res = await r.json(content_type=None)
images = []
@@ -676,7 +676,7 @@ async def image_generations(
ssl=AIOHTTP_CLIENT_SESSION_SSL,
) as r:
r.raise_for_status()
res = await r.json()
res = await r.json(content_type=None)
images = []
@@ -785,7 +785,7 @@ async def image_generations(
headers={'authorization': get_automatic1111_api_auth(request)},
ssl=AIOHTTP_CLIENT_SESSION_SSL,
) as r:
res = await r.json()
res = await r.json(content_type=None)
log.debug(f'res: {res}')
images = []
@@ -960,7 +960,7 @@ async def image_edits(
ssl=AIOHTTP_CLIENT_SESSION_SSL,
) as r:
r.raise_for_status()
res = await r.json()
res = await r.json(content_type=None)
images = []
for image in res['data']:
@@ -1015,7 +1015,7 @@ async def image_edits(
ssl=AIOHTTP_CLIENT_SESSION_SSL,
) as r:
r.raise_for_status()
res = await r.json()
res = await r.json(content_type=None)
images = []
for image in res['candidates']: