mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5099] [Bug]: Gallery conversation selfies return 404 on Windows after v2.4.2 #2821
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#2821
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/5099
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Gallery images, especially Conversation selfies, fail to display with HTTP 404 on Windows after updating to Marinara Engine v2.4.2. The files remain valid and exist on disk, and the Gallery listing endpoint still returns their metadata and prompts. Connection-profile test images continue to work.
Affected environment
start.bat→npm start→node packages/server/dist/index.jsObserved behavior
/api/gallery/file/:chatId/:filenamereturn 404.Expected behavior
Valid Gallery files contained within the configured Gallery directory should be served successfully on Windows while traversal and symlink escapes remain rejected.
Root-cause analysis
The Gallery route resolves and constrains the stored path through
resolveStoredGalleryFile(image.filePath, GALLERY_DIR), which usesassertInsideDir. It then performs a second gate throughvalidateImageAssetFile.validateImageAssetFilecallsresolveAllowedMediaPathinpackages/server/src/utils/media-file-security.ts. That helper usesfs.realpath()for both the requested file and each configured root, then relies on a case-sensitive string-prefix comparison. On Windows, canonical paths may differ because of drive-letter casing, junctions, or redirected/OneDrive paths. A valid Gallery file can therefore fail the prefix check, returnnull, and be surfaced as 404.Connection-profile test images bypass this validation path, explaining why they remain unaffected.
Temporary local workaround
The reporter patched
packages/server/dist/routes/gallery.routes.jsand replaced thevalidateImageAssetFile/sendValidatedMediaFilecall with direct file reading and a content type derived from the extension. That restored Gallery images fornpm startbecause it runs the compileddistoutput.This compiled-output patch is diagnostic only and should not be adopted directly upstream: it will be lost on rebuild and bypasses the shared media validation and streaming behavior.
Suggested upstream direction
Fix the TypeScript source and retain defense in depth. Prefer making
resolveAllowedMediaPathcompare canonical Windows paths correctly, including case-insensitive drive/path comparison where appropriate, while continuing to reject files outside all allowed roots. The Gallery route can also passGALLERY_DIRexplicitly asadditionalRootif needed, but that alone may not address canonicalization mismatches.Acceptance criteria
GALLERY_DIR.start.bat.@SpicyMarinara commented on GitHub (Aug 15, 2026):
SpicyMarinara is taking this in
fix/5099-windows-gallery-paths; a draft PR will be linked as soon as the regression fix is committed.