python-discord / sir-lancebot

A Discord bot started as a community project for Hacktoberfest 2018, later evolved to an introductory project for aspiring new developers starting out with open source development.
MIT License
242 stars 239 forks source link

KeyError: 'draft' #928

Open sentry-io[bot] opened 2 years ago

sentry-io[bot] commented 2 years ago

Sentry Issue: SIR-LANCEBOT-6X

KeyError: 'draft'
  File "discord/ext/commands/core.py", line 167, in wrapped
    ret = await coro(*args, **kwargs)
  File "bot/exts/utilities/issues.py", line 211, in issue
    results = [await self.fetch_issues(number, repository, user) for number in numbers]
  File "bot/exts/utilities/issues.py", line 211, in <listcomp>
    results = [await self.fetch_issues(number, repository, user) for number in numbers]
  File "bot/exts/utilities/issues.py", line 142, in fetch_issues
    if pull_data["draft"]:

Unhandled command error: 'draft'
katimoth commented 2 years ago

Can someone supply more details about this? I don't have authorization to view the issue in Sentry. It would be helpful to have a steps-to-reproduce or something similar. Thanks!

ChrisLovering commented 2 years ago

Can someone supply more details about this? I don't have authorization to view the issue in Sentry. It would be helpful to have a steps-to-reproduce or something similar. Thanks!

Looking at the error, it mentions File "bot/exts/utilities/issues.py", line 142, in fetch_issues.

That leads me to this line https://github.com/python-discord/sir-lancebot/blob/main/bot/exts/utilities/issues.py#L142

So it seems pull_data here is the response from GitHub converted to a dict using .json().

Since this is a KeyError, this suggests that the response from GitHub's API doesn't always return a draft key, so we should handle that.

HassanAbouelela commented 2 years ago

There really isn’t much else to this. The command ran was pr 919, which does not currently produce an error. The original triggering message has been deleted, but it doesn’t add any useful context here.

I can only assume the API returned something unexpected, so let’s just add a check for that.

katimoth commented 2 years ago

@ChrisLovering Thank you! Could you assign me and @evgriff to this?

ChrisLovering commented 2 years ago

@ChrisLovering Thank you! Could you assign me and @evgriff to this?

I've assigned you to the issue. I can't assign the other person, as I can only assign people who have commented.

onerandomusername commented 2 years ago

this would be fixed as part of #968, if not fixed as part of #778 (which is waiting on one approval)

HassanAbouelela commented 2 years ago

I believe this has been resolved with #778, closing.

onerandomusername commented 2 years ago

I believe this has been resolved with https://github.com/python-discord/sir-lancebot/pull/778, closing.

This was not fixed with #778. https://github.com/python-discord/sir-lancebot/blob/657aaf5f613b0bd219d67c71f7dc37ede0bb6aab/bot/exts/utilities/githubinfo.py#L129-L130

onerandomusername commented 2 years ago

I believe this has been resolved with #778, closing.

This was not fixed with #778.

https://github.com/python-discord/sir-lancebot/blob/657aaf5f613b0bd219d67c71f7dc37ede0bb6aab/bot/exts/utilities/githubinfo.py#L129-L130

@HassanAbouelela