PeterCat12 / pysmash

A python wrapper to smash.gg Developer API
22 stars 11 forks source link

KeyError when retrieving sets from bracket without sets #20

Closed LuNoX closed 7 years ago

LuNoX commented 7 years ago

When accessing a bracket's sets that doesn't have any (because it i.e. doesn't have any participants yet) like this:

sets = smash.bracket_show_sets(bracket_id_of_bracket_that_doesnt_have_sets)

you get this:

In get Sets:
  File "C:\Program Files\Python35\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\Timo\PycharmProjects\Smashy-Bot\cogs\smashy.py", line 85, in get_sets
    sets = smash.bracket_show_sets(bracket)
  File "C:\Program Files\Python35\lib\site-packages\pysmash\smashgg.py", line 53, in bracket_show_sets
    return brackets.sets(bracket_id, filter_response)
  File "C:\Program Files\Python35\lib\site-packages\pysmash\brackets.py", line 24, in sets
    response = _filter_set_response(response)
  File "C:\Program Files\Python35\lib\site-packages\pysmash\brackets.py", line 111, in _filter_set_response
    bracket_sets = response['entities']['sets']
KeyError: 'sets'
LuNoX commented 7 years ago

This also applies to any other functions accessing sets (for example tournament_show_sets())

PeterCat12 commented 7 years ago

Thanks again for the issue LuNoX. I'll try to get around to this one tonight. Would you mind sending me a bracket_id that is producing the error?

LuNoX commented 7 years ago

There you go: 273024

PeterCat12 commented 7 years ago

Fixed in 1.2.4. Try upgrading the pip package (you may have to uninstall and the reinstall it, at least I did when I tested).