Unhandled format of the location string
ShingenPizza opened this issue · 4 comments
Yesterday I've received a message from my Telegram bot that monitors VRC activity of me and a group of my friends with an information that it failed to process a location string, in a way shown below:
>>> friends = client.fetch_full_friends(offline=False)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Python38\lib\site-packages\vrcpy\client.py", line 66, in fetch_full_friends
friends.append(friend.fetch_full())
File "C:\Python38\lib\site-packages\vrcpy\objects.py", line 135, in fetch_full
return User(self.client, resp["data"])
File "C:\Python38\lib\site-packages\vrcpy\objects.py", line 202, in __init__
if not obj == None: self._assign(obj)
File "C:\Python38\lib\site-packages\vrcpy\objects.py", line 27, in _assign
setattr(self, key, self.types[key](self.client, obj[key]))
File "C:\Python38\lib\site-packages\vrcpy\objects.py", line 474, in __init__
self.name, t, nonce = location.split("~")
ValueError: not enough values to unpack (expected 3, got 2)
>>> friends = client.fetch_friends(offline=False)
... for f in friends:
... print(f.location)
...
wrld_a015e11d-7ce8-42ed-8389-aa78104cff8c:7965~public
It's rare (happened only this one time during a couple of weeks), but it did happen. Would you like to add handling of this format and/or some kind of general error handling? If you're not feeling like doing it yourself i could create a pull request.
PS: is it intended that fetch_friends()
leaves the .location
as a string, while fetch_full_friends()
turns it into a Location
object? it doesn't request any additional data, so i don't know if it's necessary to leave it like that (although it did help me to find that invalid string).
That's interesting, until recently it was thought that limited user objects don't have a location attribute (See here), it seems VRC backend either was updated or it's just really rare (there is no formatting/separate object for location of fetch_friends because it's never expected to get one).
I'll do my best to fix it up based on the error you provided, though I can't be sure it will work since I'm unable to reproduce it.
Also, feel free to make pull requests to fix things you find if you would like to, I'd love some help on this project! Thank you for reporting this!
Please reopen this if this error comes up again!
it seems VRC backend either was updated or it's just really rare
location being there is not rare, i'm pretty sure i fetched location strings with fetch_friends
consistently since i started my project about 3 weeks ago, so it's probably the it-was-updated option.
https://vrchatapi.github.io/#/README says
As of late, this documentation has become quite outdated, many of the endpoints have changed since the last update,
Ah ok, I guess so then.
That comment was made in February, since then it's been updated quite a bit