Closed Steauxback closed 1 year ago
Hmm, it should always have the data key, at least based on the docs. Nor can I reproduce it - multiple results seem to work fine. It should be easy enough to handle this error more gracefully though.
0877a018375b6a994af9b49d60f1637a7a9a1cc9 and 5d5b770dd1844e990e18dc703cf46668c8eb6285 make some changes so that it'll report no results when this happens instead of throwing an error (update with cog update
). If it is triggering when there should be results then we still have a problem, but I can't really diagnose that until I can reproduce it :/
Thanks,
I did a couple of test and here are the results :
So after multiple test (kanka refresh done after each change) I got this :
If one of the result is visible only to admin the search do not work (user of the bot have same view as my players) Ex : "Anne Doral" visible for all, "Anne 1" visible admin only, searching "Anne" do not work, "Anne D" will return result.
If new character is created visible for all but race is not specified search fail until race have been set to the new character, even if this character will not be displayed (Ex : new character is "Anne 2", seach for "Anne Doral" will not work until race is set. Characters existing previously without race do not seem to cause issue but new ones does. [17:09:42] ERROR Exception in command 'kanka search' [red] ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ /home/steauxback/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py:85 in wrapped │ │ ❱ 85 ret = await coro(*args, **kwargs) │ │ /home/steauxback/.local/share/Red-DiscordBot/data/StbRedBot1/cogs/CogManager/cogs/kankaview/kankaview.py:999 in display_search │ │ ❱ 999 await self.display_character(ctx, id) │ │ /home/steauxback/.local/share/Red-DiscordBot/data/StbRedBot1/cogs/CogManager/cogs/kankaview/kankaview.py:560 in display_character │ │ ❱ 560 char = await self._get_entity(await self._active(ctx), 'characters', │ │ /home/steauxback/.local/share/Red-DiscordBot/data/StbRedBot1/cogs/CogManager/cogs/kankaview/kankaview.py:308 in _get_entity │ │ ❱ 308 return Character(campaign_id, j['data']) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ KeyError: 'data'
I have a character "Lord Danesh" for which searching "Danesh" is not working (working in kanka) but "Lord Danesh" is working, getting Entity not found. in discord and no error on console.
Also I have location "Ambre (Cite)" (multiple objects with Ambre in name but only location). If i do a kanka search for "Ambre" I get "Entity not found." (was giving error from first post in console before patch) If i do a kanka search for "Ambre (" it is working. If i do a kanka location for "Ambre (" it is working. If i do a kanka location for "Ambre" I get this error :
[17:16:46] ERROR Exception in command 'kanka location' [red] ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ /home/steauxback/.local/share/Red-DiscordBot/data/StbRedBot1/cogs/CogManager/cogs/kankaview/kankaview.py:439 in _process_display_input │ │ ❱ 439 id = int(input) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ValueError: invalid literal for int() with base 10: 'Ambre'
During handling of the above exception, another exception occurred:
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ /home/steauxback/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py:85 in wrapped │ │ ❱ 85 ret = await coro(*args, **kwargs) │ │ /home/steauxback/.local/share/Red-DiscordBot/data/StbRedBot1/cogs/CogManager/cogs/kankaview/kankaview.py:602 in display_location │ │ ❱ 602 id = await self._process_display_input(ctx, input, 'location', alert) │ │ /home/steauxback/.local/share/Red-DiscordBot/data/StbRedBot1/cogs/CogManager/cogs/kankaview/kankaview.py:442 in _process_display_input │ │ ❱ 442 entity = await self._search(await self._active(ctx), │ │ /home/steauxback/.local/share/Red-DiscordBot/data/StbRedBot1/cogs/CogManager/cogs/kankaview/kankaview.py:426 in _search │ │ ❱ 426 for result in j.get('data'): │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ TypeError: 'NoneType' object is not iterable
I tried to clean the object by removing entry description, link to other objects, image etc. I tried to rename it Ambre only, and set Type value, it still get the error.
I can reproduce the second issue now! That extra information was very helpful, thank you. It looks like the root cause is that the API is breaking in these cases. I'll report it as a Kanka bug.
I've pushed some fixes and some changes that should provide some additional debug information. If you update then launch the bot with the dev flag (i.e. redbot yourBotsName --dev
it'll start logging more information about requests. With that we will hopefully be able to see what exactly is causing things to go wrong.
First thank you so much to share this Cog!
Here the issue : If there are multiple results possible to a search we get
Error in command 'kanka search'. Check your console or logs for details.
Server : [18:52:19] ERROR Exception in command 'kanka search' [red] ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ /home/steauxback/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py:85 in wrapped │ │ ❱ 85 ret = await coro(*args, **kwargs) │ │ /home/steauxback/.local/share/Red-DiscordBot/data/StbRedBot1/cogs/CogManager/cogs/kankaview/kankaview.py:989 in display_search │ │ ❱ 989 entity = await self._search(await self._active(ctx), query) │ │ /home/steauxback/.local/share/Red-DiscordBot/data/StbRedBot1/cogs/CogManager/cogs/kankaview/kankaview.py:429 in _search │ │ ❱ 429 elif j['data']: │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ KeyError: 'data'