FancyModLoader icon indicating copy to clipboard operation
FancyModLoader copied to clipboard

Version Checker accepts erroneous HTTP status codes

Open UpcraftLP opened this issue 8 months ago • 0 comments

The FML version checker currently ignores the received HTTP status code and treats every response as a success. This is with the exception of 3xx codes, which for some reason have special handling rather than being set as a redirect policy on the HttpClient.

In practice this means any error codes (4xx or 5xx) will be silently swallowed, and instead of just printing the raw response text in those cases, the version checker still tries to parse the response as a JSON object. This results in HTTP errors being logged as json parsing errors some time after the request, with no relation to said request (this can be an issue if there are other log statements inbetween, due to the parallel nature of mod loading).

Therefore I suggest:

  • remove the custom 3xx handling and set a redirect policy on the HttpClient
  • check the HTTP status code to be 200 (intentionally not 2xx; 200 is the only case in which the response would be valid)
  • if the response status code is not 200, log an error containing the request URL, response status code and the raw response text, if any. do not proceed to try and parse the response as JSON

UpcraftLP avatar Apr 22 '25 00:04 UpcraftLP