[GH-ISSUE #8422] [Issue]: Grok images without a reference picture arrive as a doubled data URL and break #8352

Closed
opened 2026-11-07 16:42:24 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @SpicyMarinara on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8422

Originally assigned to: @SpicyMarinara on GitHub.

Summary

A Grok (xAI) image with no reference picture fails or comes out broken, although xAI generates it and bills for it. xAI's generations endpoint fills b64_json with a whole data URL (data:image/jpeg;base64,…). generateXAI passes it on unchanged as the base64 of a PNG, so callers build data:image/png;base64,data:image/jpeg;base64,… and decode garbage bytes.

Expected behavior

The image arrives as the JPEG xAI returned, with the right type.

Actual behavior

The decoded bytes are not an image. In Otome Hearth, every archetype love interest's look (painted with no reference picture) failed on every Grok connection, while card characters, which send their avatar and so use xAI's edits endpoint (answered with a URL), painted fine. xAI's own request log shows each image generated (numInputImages: 0, mimeType: image/jpeg).

The same path serves the Engine's own avatar generation with no reference, and any package painting someone with no avatar on Grok.

Steps to reproduce

  1. Add an xAI image connection (for example grok-imagine-image-2.0).
  2. Generate an image with no reference picture, for example a new avatar with no source image, or an Otome Hearth archetype love interest's look.
  3. The image fails to save or shows as broken; xAI's console shows it was generated.

Environment

  • Marinara Engine version: staging (a3f34f0d9)
  • Install type: docker
  • OS + version: any
  • Browser or app shell: any

Logs, screenshots, or video

xAI request log (ids removed): "response": { "images": [{ "base64": "data:image/jpeg;base64,/9j/4AAQ…", "mimeType": "image/jpeg" }] }.

packages/server/src/services/image/image-generation.ts, generateXAI: if (result?.b64_json) return { base64: result.b64_json, mimeType: "image/png", ext: "png" };

Additional context

NanoGPT's reader already decodes a data URL in b64_json (decodeImageDataUrl). The shared OpenAI-compatible reader and Together AI also label every b64_json PNG. Otome Hearth carries a package-side shim until this is fixed (Pasta-Devs/Marinara-Agents#1844).

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8422 Originally assigned to: @SpicyMarinara on GitHub. ## Summary A Grok (xAI) image with no reference picture fails or comes out broken, although xAI generates it and bills for it. xAI's generations endpoint fills `b64_json` with a whole data URL (`data:image/jpeg;base64,…`). `generateXAI` passes it on unchanged as the base64 of a PNG, so callers build `data:image/png;base64,data:image/jpeg;base64,…` and decode garbage bytes. ## Expected behavior The image arrives as the JPEG xAI returned, with the right type. ## Actual behavior The decoded bytes are not an image. In Otome Hearth, every archetype love interest's look (painted with no reference picture) failed on every Grok connection, while card characters, which send their avatar and so use xAI's edits endpoint (answered with a URL), painted fine. xAI's own request log shows each image generated (`numInputImages: 0`, `mimeType: image/jpeg`). The same path serves the Engine's own avatar generation with no reference, and any package painting someone with no avatar on Grok. ## Steps to reproduce 1. Add an xAI image connection (for example `grok-imagine-image-2.0`). 2. Generate an image with no reference picture, for example a new avatar with no source image, or an Otome Hearth archetype love interest's look. 3. The image fails to save or shows as broken; xAI's console shows it was generated. ## Environment - Marinara Engine version: staging (a3f34f0d9) - Install type: docker - OS + version: any - Browser or app shell: any ## Logs, screenshots, or video xAI request log (ids removed): `"response": { "images": [{ "base64": "data:image/jpeg;base64,/9j/4AAQ…", "mimeType": "image/jpeg" }] }`. `packages/server/src/services/image/image-generation.ts`, `generateXAI`: `if (result?.b64_json) return { base64: result.b64_json, mimeType: "image/png", ext: "png" };` ## Additional context NanoGPT's reader already decodes a data URL in `b64_json` (`decodeImageDataUrl`). The shared OpenAI-compatible reader and Together AI also label every `b64_json` PNG. Otome Hearth carries a package-side shim until this is fixed (Pasta-Devs/Marinara-Agents#1844). ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-11-07 16:42:24 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8352
No description provided.