[GH-ISSUE #5147] [Issue]: JPEG gallery images saved with .png extension return 404 #2844

Closed
opened 2026-10-21 05:56:45 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Chat-generated images saved to a character gallery can exist on disk but fail to load because JPEG bytes are saved with a .png filename. The gallery file route rejects the mismatched format and returns 404.

Expected behavior

Generated gallery images should be saved with an extension matching their actual image format and should be served successfully.

Actual behavior

Images returned as JPEG bytes are saved with a .png filename. The gallery serving route validates that the sniffed format matches the filename extension, rejects the files, and returns 404 even though the files exist on disk.

Steps to reproduce

  1. Generate an image in chat using an affected image provider or model that returns JPEG data.
  2. Save the generated image to a character gallery.
  3. Attempt to view the saved image through the character gallery.
  4. Observe that the image returns 404 or appears broken.

Environment

  • Marinara Engine version: 2.4.3 (build 2.4.3+068d01faddf9, commit 068d01fadd)
  • Install type: Not provided
  • OS + version: Windows 10.0
  • Browser or app shell: Chrome 150.0.0.0 (Mozilla/5.0; Windows NT 10.0; Win64; x64)

Logs, screenshots, or video

Stored file gallery/shared/539R4JF0pEossAaI9eWB1.png begins with JFIF/C2PA markers, indicating JPEG data. The failing route is /api/characters/:id/gallery/file/:filename; validateImageAssetFile calls validateImageAssetBuffer, which requires the detected format to match the filename extension.

Additional context

Affected providers reported include NanoGPT, qwen-image-2.0-pro, and qwen-image-max-edit. The active connection was nano Seed Dance Edit with provider image_generation and model bytedance/seedream-v5.0-pro/edit. Possible fixes are detecting the actual format when saving the file or remapping the served type based on detected content during validation.

Discord thread: gallery images generated in chat show broken/404 — JPEG bytes saved with .png extension
Discord thread link: https://discord.com/channels/1417099416812392641/1538558001902915684
Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653)

Discord thread transcript (2 messages)
[2026-08-16T14:40:12.679Z] Waylander: Bug: gallery images generated in chat show broken/404 — JPEG bytes saved with .png extension

Chat-generated images saved to a character gallery 404 when served, even though the file exists on disk. Root cause: the image provider (NanoGPT / qwen-image-2.0-pro / qwen-image-max-edit) returns JPEG bytes, but Marinara saves them with a .png filename. The serving route (/api/characters/:id/gallery/file/:filename) runs validateImageAssetFile → validateImageAssetBuffer, which requires the sniffed format to match the filename extension (media-file-security.ts:315). JPEG-in-a-.png-file fails validation → 404. Confirmed by reading a stored file: gallery/shared/539R4JF0pEossAaI9eWB1.png begins with JFIF/C2PA markers. Fix would be either detecting the actual format at save time, or permissive re-mapping (serve as detected type) at validation time. Affected: any image whose provider returned JPEG while Marinara assumed PNG.

Marinara Engine diagnostics
Version: 2.4.3
Build: 2.4.3+068d01faddf9
Commit: 068d01faddf9
OS: Windows 10.0
Browser / app shell: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36
GPU: ANGLE (NVIDIA, NVIDIA GeForce RTX 3090 (0x00002204) Direct3D11 vs_5_0 ps_5_0, D3D11)
Active connection: nano Seed Dance Edit
Connection provider: image_generation
LLM model: bytedance/seedream-v5.0-pro/edit
[Discord message: https://discord.com/channels/1417099416812392641/1538558001902915684/1538558001902915684]

[2026-08-16T14:40:13.359Z] Professor Mari [bot]: Howdy!

Thank you for submitting a new bug report/feature request, your support means a lot. A member of the team will look into it as soon as possible, and if they find it valid, they will open a GitHub Issue out of it. You can check whether it was addressed on the staging build of Marinara Engine. **Do not ping any of the developers, this will not speed up the process.**

**Please include a Support Diagnostic in the post if you haven't done it yet.** Otherwise, ignore this step. To grab it, go to the Marinara Engine tab:

`Settings -> Advanced -> Support Diagnostics -> Copy Support Diagnostics.`

Thank you, this will help tremendously.

This is an automated message, but if you reply to it, I will do my best to assist you using my LLM-powered brain. That said, it's best for a human to handle this case.

Cheers!
[Discord message: https://discord.com/channels/1417099416812392641/1538558001902915684/1538558004755169392]

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Aug 16, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5147 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Chat-generated images saved to a character gallery can exist on disk but fail to load because JPEG bytes are saved with a .png filename. The gallery file route rejects the mismatched format and returns 404. ## Expected behavior Generated gallery images should be saved with an extension matching their actual image format and should be served successfully. ## Actual behavior Images returned as JPEG bytes are saved with a .png filename. The gallery serving route validates that the sniffed format matches the filename extension, rejects the files, and returns 404 even though the files exist on disk. ## Steps to reproduce 1. Generate an image in chat using an affected image provider or model that returns JPEG data. 2. Save the generated image to a character gallery. 3. Attempt to view the saved image through the character gallery. 4. Observe that the image returns 404 or appears broken. ## Environment - Marinara Engine version: 2.4.3 (build 2.4.3+068d01faddf9, commit 068d01faddf9) - Install type: Not provided - OS + version: Windows 10.0 - Browser or app shell: Chrome 150.0.0.0 (Mozilla/5.0; Windows NT 10.0; Win64; x64) ## Logs, screenshots, or video Stored file gallery/shared/539R4JF0pEossAaI9eWB1.png begins with JFIF/C2PA markers, indicating JPEG data. The failing route is /api/characters/:id/gallery/file/:filename; validateImageAssetFile calls validateImageAssetBuffer, which requires the detected format to match the filename extension. ## Additional context Affected providers reported include NanoGPT, qwen-image-2.0-pro, and qwen-image-max-edit. The active connection was nano Seed Dance Edit with provider image_generation and model bytedance/seedream-v5.0-pro/edit. Possible fixes are detecting the actual format when saving the file or remapping the served type based on detected content during validation. Discord thread: gallery images generated in chat show broken/404 — JPEG bytes saved with .png extension Discord thread link: https://discord.com/channels/1417099416812392641/1538558001902915684 Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653) <details> <summary>Discord thread transcript (2 messages)</summary> ```text [2026-08-16T14:40:12.679Z] Waylander: Bug: gallery images generated in chat show broken/404 — JPEG bytes saved with .png extension Chat-generated images saved to a character gallery 404 when served, even though the file exists on disk. Root cause: the image provider (NanoGPT / qwen-image-2.0-pro / qwen-image-max-edit) returns JPEG bytes, but Marinara saves them with a .png filename. The serving route (/api/characters/:id/gallery/file/:filename) runs validateImageAssetFile → validateImageAssetBuffer, which requires the sniffed format to match the filename extension (media-file-security.ts:315). JPEG-in-a-.png-file fails validation → 404. Confirmed by reading a stored file: gallery/shared/539R4JF0pEossAaI9eWB1.png begins with JFIF/C2PA markers. Fix would be either detecting the actual format at save time, or permissive re-mapping (serve as detected type) at validation time. Affected: any image whose provider returned JPEG while Marinara assumed PNG. Marinara Engine diagnostics Version: 2.4.3 Build: 2.4.3+068d01faddf9 Commit: 068d01faddf9 OS: Windows 10.0 Browser / app shell: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 GPU: ANGLE (NVIDIA, NVIDIA GeForce RTX 3090 (0x00002204) Direct3D11 vs_5_0 ps_5_0, D3D11) Active connection: nano Seed Dance Edit Connection provider: image_generation LLM model: bytedance/seedream-v5.0-pro/edit [Discord message: https://discord.com/channels/1417099416812392641/1538558001902915684/1538558001902915684] [2026-08-16T14:40:13.359Z] Professor Mari [bot]: Howdy! Thank you for submitting a new bug report/feature request, your support means a lot. A member of the team will look into it as soon as possible, and if they find it valid, they will open a GitHub Issue out of it. You can check whether it was addressed on the staging build of Marinara Engine. **Do not ping any of the developers, this will not speed up the process.** **Please include a Support Diagnostic in the post if you haven't done it yet.** Otherwise, ignore this step. To grab it, go to the Marinara Engine tab: `Settings -> Advanced -> Support Diagnostics -> Copy Support Diagnostics.` Thank you, this will help tremendously. This is an automated message, but if you reply to it, I will do my best to assist you using my LLM-powered brain. That said, it's best for a human to handle this case. Cheers! [Discord message: https://discord.com/channels/1417099416812392641/1538558001902915684/1538558004755169392] ``` </details> ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:56:45 +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#2844
No description provided.