fix: ensure HTTP code is returned when image file is missing (404) or unreadable (500) - #5526
Draft
eduardomozart wants to merge 1 commit into
Draft
fix: ensure HTTP code is returned when image file is missing (404) or unreadable (500)#5526eduardomozart wants to merge 1 commit into
eduardomozart wants to merge 1 commit into
Conversation
eduardomozart
force-pushed
the
fix/applist-cover-404-500
branch
from
August 18, 2026 23:48
248158b to
069eacf
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
This PR resolves a critical network stream bug in
/appasset(Moonlight streaming protocol) endpoint.When Sunshine is asked to serve an image file & fallback image file (
box.png) that is missing or locked/unreadable due to insufficient permissions,std::ifstreamsilently fails to open the file. Prior to this fix, the code did not verify if the stream successfully opened (in.is_open()), and instead blindly proceeded to calculate the content length usingtellg(). On a failed stream,tellg()returns-1, which was incorrectly cast to a 64-bit unsigned integer (yielding a massive impossibleContent-Lengthlike18446744073709551615). This invalid header abruptly aborted the connection via libcurl.This issue specifically impacted Moonlight clients (like Moonlight Tizen). When a custom app image was inaccessible and the fallback
box.pngwas also unreadable, the connection abortion threw a crypticWeird server reply(libcurl: 8) error but HTTP 200, breaking the fetch process completely.This commit adds
if (!in.is_open())safeguards toappasset()innvhttp.cpp. It also adds astd::filesystem::exists()check to differentiate the HTTP response correctly:404 Not Found.500 Internal Server Error.After the fix:
Sunshine gracefully catches the file read failure, logs the warning, and safely returns a 500 or 404 response without breaking the network stream. The stream stays alive to handle subsequent background
/serverinfopings:text [2026-08-18 18:41:56.480]: Debug: METHOD :: GET [2026-08-18 18:41:56.480]: Debug: DESTINATION :: /appasset ... [2026-08-18 18:41:56.481]: Warning: Invalid PNG file at path ["../Resources/assets/desktop-alt.png"] [2026-08-18 18:41:56.920]: Debug: /CN=NVIDIA GameStream Client -- verified [2026-08-18 18:41:56.920]: Debug: TUNNEL :: HTTPS [2026-08-18 18:41:56.920]: Debug: METHOD :: GET [2026-08-18 18:41:56.920]: Debug: DESTINATION :: /serverinfoMoonlight Tizen safely catches the standard HTTP error, gracefully abandons the download, and uses its local fallback placeholder:
CURL: https://192.168.1.73:47984/appasset?uniqueid=... -> HTTP response code said errorBefore the fix:
Sunshine attempts to serve the file and immediately crashes the libcurl connection due to the
-1Content-Length. The Sunshine logs abruptly end after the/appassetrequest because the stream dies:text [2026-08-18 18:41:56.480]: Debug: METHOD :: GET [2026-08-18 18:41:56.480]: Debug: DESTINATION :: /appasset [2026-08-18 18:41:56.480]: Debug: appid -- 427450027Moonlight Tizen fails to fetch the image and receives a crashed connection because of the massive unsigned
Content-Length, logging:CURL: https://192.168.1.73:47984/appasset?uniqueid=... -> Weird server replyReproducible Steps (using Web UI proxy)
Because hitting the mutual-TLS
/appassetendpoint is complex from a standard CLI, you can easily reproduce the exact same C++tellg()bug via the Web UI.icoendpoint:chmod 000 assets/web/images/sunshine.icocurl -v -k https://localhost:47990/images/sunshine.icocurl: (8) Weird server replyand an impossible Content-Length.< HTTP/1.1 500 Internal Server Error(or404 Not Foundif you delete the file).Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage
See our AI usage policy.