PublicAPI icon indicating copy to clipboard operation
PublicAPI copied to clipboard

Guild parsing fails on too large experience

Open Rigner opened this issue 2 years ago • 1 comments

Hey,

I noticed a parsing error when fetching the guild for a user, because the experience amount was too large and was encoding as a double instead of a long: "1.6434933249E12".

The field just needs to be changed from a long to a double.

Can be reproduced here: https://api.hypixel.net/guild?key=KEY&player=9d7eccf5-2a1e-419f-9864-312c22208f07

Rigner avatar Apr 28 '22 16:04 Rigner

https://api.hypixel.net/guild?key=KEY&player=bcdb84f3-5534-4c7e-9d61-cc1829670ec4

Just saw another case, where timestamps are also doubles.

Rigner avatar May 30 '22 14:05 Rigner

Bumping this to get the PR merged, still an issue (I'm using a fork version anyways, but yeah would be cool to fix here too).

Rigner avatar Nov 23 '22 05:11 Rigner

This issue is still occuring, like I said it must be a double and not a long.

Rigner avatar Jun 19 '23 12:06 Rigner

I'm pretty sure they are never doubles, do you have an example of one with a double? The example given in the original post is a long, just in a scientific notation

ConnorLinfoot avatar Jun 19 '23 20:06 ConnorLinfoot

Indeed it's scientific notation, but iirc I was seeing issues with Gson failing to parse it back to a long. Will test again when I can

Rigner avatar Jun 20 '23 15:06 Rigner

You can't parse scientific notation into long

jshell> Long.parseLong("1.6434933249E12")
|  Exception java.lang.NumberFormatException: For input string: "1.6434933249E12"
|        at NumberFormatException.forInputString (NumberFormatException.java:67)
|        at Long.parseLong (Long.java:708)
|        at Long.parseLong (Long.java:831)
|        at (#1:1)

jshell> Double.parseDouble("1.6434933249E12")
$2 ==> 1.6434933249E12

The solution might be to not serialize them as scientific notation in the first place, if it's the API service doing it

mdashlw avatar Jun 21 '23 00:06 mdashlw