Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got KeyError: 0 for Gelbooru Collection #41

Closed
Misaka13514 opened this issue Mar 7, 2022 · 1 comment
Closed

Got KeyError: 0 for Gelbooru Collection #41

Misaka13514 opened this issue Mar 7, 2022 · 1 comment
Labels
upstream Something not on our side

Comments

@Misaka13514
Copy link
Contributor

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Send a gelbooru collection link
  2. See error KeyError: 0

links tested (NSFW)

  • https://gelbooru.com/index.php?page=post&s=view&id=6707612
  • https://gelbooru.com/index.php?page=post&s=view&id=6322852

Expected behavior
collect the collection or show a clear error message

Error output / Logs
Logs are usually critical to identify the cause of a bug, please paste the complete log from start to end.
Make sure to remove or mask all secrets, such as bot token and personal information!

2022-03-07T11:58:39.707878+00:00 heroku[router]: at=info method=POST path="/SOME_BOT_TOKEN" host=misakah.herokuapp.com request_id=4f0ebd2e-e88c-45f5-8184-7495b85ab2ee fwd="91.108.6.78" dyno=web.1 connect=1ms service=9ms status=200 bytes=171 protocol=https
2022-03-07T11:58:39.700272+00:00 app[web.1]: 2022-03-07 11:58:39,700 - nazurin - INFO - Collection update: site=Gelbooru, match=('6707612',)
2022-03-07T11:58:39.708133+00:00 app[web.1]: 2022-03-07 11:58:39,707 - aiohttp.access - INFO - 10.1.23.249 [07/Mar/2022:11:58:39 +0000] "POST /SOME_BOT_TOKEN HTTP/1.1" 200 171 "-" "-"
2022-03-07T11:58:39.825972+00:00 app[web.1]: 2022-03-07 11:58:39,825 - nazurin - ERROR - Update {"update_id": 90486771, "message": {"message_id": 1505, "from": {"id": 673435039, "is_bot": false, "first_name": "欠陥電気", "last_name": "𝑹𝒂𝒅𝒊𝒐𝑵𝒐𝒊𝒔𝒆", "username": "Misaka_0x34ca", "language_code": "ja"}, "chat": {"id": 673435039, "first_name": "欠陥電気", "last_name": "𝑹𝒂𝒅𝒊𝒐𝑵𝒐𝒊𝒔𝒆", "username": "Misaka_0x34ca", "type": "private"}, "date": 1646654319, "text": "https://gelbooru.com/index.php?page=post&s=view&id=6707612", "entities": [{"type": "url", "offset": 0, "length": 58}]}} caused <class 'KeyError'>: 0
2022-03-07T11:58:39.826994+00:00 app[web.1]: Traceback (most recent call last):
2022-03-07T11:58:39.827084+00:00 app[web.1]:   File "/app/nazurin/__main__.py", line 54, in on_error
2022-03-07T11:58:39.827085+00:00 app[web.1]:     raise exception
2022-03-07T11:58:39.827125+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 1394, in process_response
2022-03-07T11:58:39.827125+00:00 app[web.1]:     response = task.result()
2022-03-07T11:58:39.827142+00:00 app[web.1]:   File "/app/nazurin/dispatcher.py", line 59, in update_collection
2022-03-07T11:58:39.827142+00:00 app[web.1]:     await self.bot.updateCollection(urls, message)
2022-03-07T11:58:39.827167+00:00 app[web.1]:   File "/app/nazurin/bot.py", line 112, in updateCollection
2022-03-07T11:58:39.827168+00:00 app[web.1]:     illust = await self.sites.handle_update(result)
2022-03-07T11:58:39.827189+00:00 app[web.1]:   File "/app/nazurin/sites/__init__.py", line 66, in handle_update
2022-03-07T11:58:39.827189+00:00 app[web.1]:     return await handle(result['match'])
2022-03-07T11:58:39.827205+00:00 app[web.1]:   File "/app/nazurin/sites/Gelbooru/interface.py", line 19, in handle
2022-03-07T11:58:39.827205+00:00 app[web.1]:     illust = await Gelbooru().fetch(post_id)
2022-03-07T11:58:39.827221+00:00 app[web.1]:   File "/app/nazurin/sites/Gelbooru/api.py", line 22, in fetch
2022-03-07T11:58:39.827222+00:00 app[web.1]:     post = await self.getPost(post_id)
2022-03-07T11:58:39.827237+00:00 app[web.1]:   File "/app/nazurin/sites/Gelbooru/api.py", line 18, in getPost
2022-03-07T11:58:39.827248+00:00 app[web.1]:     post = response[0]
2022-03-07T11:58:39.827282+00:00 app[web.1]: KeyError: 0
2022-03-07T11:59:10.277016+00:00 heroku[router]: at=info method=POST path="/SOME_BOT_TOKEN" host=misakah.herokuapp.com request_id=c292ca3d-18bc-4d71-9ad6-a1cb8fe88559 fwd="91.108.6.78" dyno=web.1 connect=0ms service=13ms status=200 bytes=171 protocol=https
2022-03-07T11:59:10.266812+00:00 app[web.1]: 2022-03-07 11:59:10,266 - nazurin - INFO - Collection update: site=Gelbooru, match=('6322852',)
2022-03-07T11:59:10.277338+00:00 app[web.1]: 2022-03-07 11:59:10,277 - aiohttp.access - INFO - 10.1.23.249 [07/Mar/2022:11:59:10 +0000] "POST /SOME_BOT_TOKEN HTTP/1.1" 200 171 "-" "-"
2022-03-07T11:59:10.406410+00:00 app[web.1]: 2022-03-07 11:59:10,406 - nazurin - ERROR - Update {"update_id": 90486772, "message": {"message_id": 1507, "from": {"id": 673435039, "is_bot": false, "first_name": "欠陥電気", "last_name": "𝑹𝒂𝒅𝒊𝒐𝑵𝒐𝒊𝒔𝒆", "username": "Misaka_0x34ca", "language_code": "ja"}, "chat": {"id": 673435039, "first_name": "欠陥電気", "last_name": "𝑹𝒂𝒅𝒊𝒐𝑵𝒐𝒊𝒔𝒆", "username": "Misaka_0x34ca", "type": "private"}, "date": 1646654350, "text": "https://gelbooru.com/index.php?page=post&s=view&id=6322852", "entities": [{"type": "url", "offset": 0, "length": 58}]}} caused <class 'KeyError'>: 0
2022-03-07T11:59:10.406540+00:00 app[web.1]: Traceback (most recent call last):
2022-03-07T11:59:10.406573+00:00 app[web.1]:   File "/app/nazurin/__main__.py", line 54, in on_error
2022-03-07T11:59:10.406573+00:00 app[web.1]:     raise exception
2022-03-07T11:59:10.406576+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 1394, in process_response
2022-03-07T11:59:10.406576+00:00 app[web.1]:     response = task.result()
2022-03-07T11:59:10.406586+00:00 app[web.1]:   File "/app/nazurin/dispatcher.py", line 59, in update_collection
2022-03-07T11:59:10.406586+00:00 app[web.1]:     await self.bot.updateCollection(urls, message)
2022-03-07T11:59:10.406594+00:00 app[web.1]:   File "/app/nazurin/bot.py", line 112, in updateCollection
2022-03-07T11:59:10.406594+00:00 app[web.1]:     illust = await self.sites.handle_update(result)
2022-03-07T11:59:10.406602+00:00 app[web.1]:   File "/app/nazurin/sites/__init__.py", line 66, in handle_update
2022-03-07T11:59:10.406603+00:00 app[web.1]:     return await handle(result['match'])
2022-03-07T11:59:10.406610+00:00 app[web.1]:   File "/app/nazurin/sites/Gelbooru/interface.py", line 19, in handle
2022-03-07T11:59:10.406611+00:00 app[web.1]:     illust = await Gelbooru().fetch(post_id)
2022-03-07T11:59:10.406619+00:00 app[web.1]:   File "/app/nazurin/sites/Gelbooru/api.py", line 22, in fetch
2022-03-07T11:59:10.406619+00:00 app[web.1]:     post = await self.getPost(post_id)
2022-03-07T11:59:10.406627+00:00 app[web.1]:   File "/app/nazurin/sites/Gelbooru/api.py", line 18, in getPost
2022-03-07T11:59:10.406628+00:00 app[web.1]:     post = response[0]
2022-03-07T11:59:10.406644+00:00 app[web.1]: KeyError: 0

Environment (please complete the following information):

  • latest version deployed on heroku

Additional context
This function was working fine before.
The link opens fine manually. (even works while using Heroku's IP)

@y-young y-young added the upstream Something not on our side label Mar 7, 2022
@y-young y-young closed this as completed in b29b774 Mar 7, 2022
@y-young
Copy link
Owner

y-young commented Mar 7, 2022

It seems Gelbooru changed their API response format recently.
Thanks for reporting!

dearrrfish pushed a commit to dearrrfish/nazurin that referenced this issue Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Something not on our side
Projects
None yet
Development

No branches or pull requests

2 participants