mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5108] [Issue]: Gallery images return 404 on Windows after v2.4.2 update #2823
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#2823
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
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?
Originally created by @SpicyMarinara on GitHub (Aug 15, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5108
Summary
Conversation gallery images fail to display after updating to v2.4.2 because the gallery file-serving route returns HTTP 404. Connection profile test images continue to work, and the gallery listing endpoint still displays prompts.
Expected behavior
Valid conversation gallery images should be served and displayed.
Actual behavior
Gallery image requests return HTTP 404, even though the files are valid and exist on disk. Connection profile test images are unaffected.
Steps to reproduce
Environment
Logs, screenshots, or video
HTTP 404 responses from the gallery file-serving route. No screenshots or video provided.
Additional context
The gallery listing endpoint works and shows prompts. The files exist on disk. validateImageAssetFile in packages/server/src/utils/media-file-security.ts calls resolveAllowedMediaPath, which uses fs.realpath() and can fail its path-prefix check on Windows due to drive-letter casing, junctions, or OneDrive redirects. Connection test images bypass this validation. A workaround was applied to packages/server/dist/routes/gallery.routes.js by directly serving the already-sanitized path with readFileSync and a content type based on the file extension. The TypeScript source should also be patched so the fix survives rebuilds. Potential upstream fixes include handling Windows realpath normalization, passing GALLERY_DIR as an additional root, or removing the redundant validation from the gallery route.
Discord message: Discord message from ₍ᐢ..ᐢ₎ 𝚗 𝚊 𝚝 𝚝 𝚘 – ♡
Discord message link: https://discord.com/channels/1417099416812392641/1537975955212083250/1538295003997274122
Requested by: kolache (k0lache, Discord ID 220320261780668416)
Discord message transcript (1 message)
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Aug 15, 2026):
Prof Mari says:
Here's the TL;DR for the dev team:
Bug: Gallery images (conversation selfies) fail to display with HTTP 404 after updating to v2.4.2. Connection profile test images work fine. Files are valid and exist on disk. Gallery listing endpoint works (shows prompts) but file-serving route returns 404.
Root cause: validateImageAssetFile in packages/server/src/utils/media-file-security.ts rejects valid gallery files. The function calls resolveAllowedMediaPath, which uses fs.realpath() to canonicalize both the file path and configured root paths, then checks if the file path starts with a root prefix. On Windows, realpath can canonicalize paths differently (drive letter casing, junction points, OneDrive redirects), causing the prefix check to fail → returns null → 404. Connection test images bypass validateImageAssetFile entirely, which is why they work.
Fix applied (to packages/server/dist/routes/gallery.routes.js, compiled output): Replaced the validateImageAssetFile + sendValidatedMediaFile call in the /file/:chatId/:filename route handler with a direct file serve — readFileSync + reply.send with a content-type lookup from the file extension. The path is already sanitized by resolveStoredGalleryFile + assertInsideDir earlier in the handler, so the validateImageAssetFile gate was redundant.
Suggested upstream fix: Either fix resolveAllowedMediaPath to handle Windows realpath canonicalization differences (e.g. normalize drive letter casing before prefix comparison), or pass GALLERY_DIR as additionalRoot to validateImageAssetFile, or remove the redundant validation from the gallery file-serving route since path safety is already handled.
Note: The fix was applied to compiled JS (dist/) because the user runs via start.bat → npm start → node packages/server/dist/index.js. The TypeScript source should also be patched so the fix survives rebuilds.
That's the whole saga in one page, kek. Feel free to copy-paste that to the devs.