pdinklag / MinecraftStats

A Minecraft player statistics browser for the web - supports 1.13 and later!
https://discord.gg/brH5PGG8By
Other
228 stars 54 forks source link

Invalid UUID causes unhandled exception #63

Closed tfk333 closed 5 years ago

tfk333 commented 5 years ago

When updating the profile for an invalid UUID, for example due to deletion of the associated account, an exception occurs.

updating profile for d4afcce8-fce9-427f-a8e4-780e9aff3148 ...
Traceback (most recent call last):
  File "update.py", line 141, in <module>
    profile = mojang.get_player_profile(uuid)
  File "/var/www/stats.tallcraft.com/html/mojang.py", line 13, in get_player_profile
    profile = json.loads(response.read().decode())
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "update.py", line 159, in <module>
    print('failed to update profile for ' + player['name'] + ' (' + uuid + ')')
KeyError: 'name'
Trikolon commented 5 years ago

Duplicate of #61 I think. But good job on finding out what the cause might be.

pdinklag commented 5 years ago

Yes, looks like the same as #61. Why do you think the UUID is invalid? Is that just a guess or may it be a good hint?

EDIT: Sorry, I should learn to read. Thanks for the hint!

pdinklag commented 5 years ago

Closing this, see #61 for updates.