buttonmen-dev / buttonmen

Buttonmen - an online dice game
Other
16 stars 24 forks source link

Log error message on API response json_encode() failure #2985

Closed cgolubi1 closed 2 months ago

cgolubi1 commented 2 months ago

Testing:

cgolubi1 commented 2 months ago

Manual testing on a local docker site:

            $output['data']['foobar'] = NAN;

Then loaded a forum page, and verified that i got no output on the page, and the error log got:

[Sun Sep 01 19:22:54.167891 2024] [:error] [pid 1216] [client 172.17.0.1:36850] Response to API call array (\n  'type' => 'loadPlayerName',\n) failed json_encode(): Inf and NaN cannot be JSON encoded, referer: http://127.0.0.1:8080/ui/forum.html
cgolubi1 commented 2 months ago

The replay site has played 1500 games, and hasn't logged any error messages or seen any failures, so i think that's all we're going to get from that smoke test.

cgolubi1 commented 2 months ago

CaptConstruct did some smoke-testing on the dev site. Per discord:

I did some stuff in my profile, joined a few open games, selected die sizes, flipped through some of the other pages.

[As of now, there are no error log messages from the new code, or any other surprising error log messages, on that dev site. Again, this is what we'd expect, because we're not aware of any bugs on the current sites that cause JSON encoding failures.]

cgolubi1 commented 2 months ago

I'm going to take the replay site down.

Shadowshade, when you get a chance, let me know if this seems okay to merge, if you have concerns about the code, or if there's anything else you want to see tested.

blackshadowshade commented 2 months ago

This looks fine to me. Merging now.