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

V1.2.5 throws KeyError when API is misbehaving, 1.3.1 shares the same code #2572

Closed
nekokatt opened this issue Feb 18, 2020 · 8 comments
Closed

Comments

@nekokatt
Copy link

@nekokatt nekokatt commented Feb 18, 2020

At the time of writing, the API is having latency issues. Responses are still coming back, but content-type headers are missing which is causing a key error to raise rather than an internal server error.

I am aware I am using an outdated library version, but inspecting the source for 1.3.1, no mitigation has been made for this issue, so this will impact 1.3.1 as well.

No clue what the body is causing it, but it is being triggered by editing messages:

Traceback (most recent call last):
  File "/neko3/.venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "/neko3/neko3/features/ping_pong.py", line 124, in ping_command
    await msg.edit(content="", embed=embed)
  File "/neko3/.venv/lib/python3.8/site-packages/discord/message.py", line 744, in edit
    data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
  File "/neko3/.venv/lib/python3.8/site-packages/discord/http.py", line 162, in request
    data = await json_or_text(r)
  File "/neko3/.venv/lib/python3.8/site-packages/discord/http.py", line 43, in json_or_text
    if response.headers['content-type'] == 'application/json':
KeyError: 'content-type'

Corresponds to L164 on 4cf5f792d402fe8f6fea054c87da7f460a594aa0 in http.py

This has occurred three times within 10 minutes. Probably worth putting something in to check for this in the future and provide a meaningful exception instead to be safe.

@Rapptz

This comment has been minimized.

Copy link
Owner

@Rapptz Rapptz commented Feb 18, 2020

Cloudflare responses seem to no longer specify that it's HTML text via content type like it used to. Considering this has never come up in 4 years it must be a recent change on their end.

@skyblockz

This comment has been minimized.

Copy link

@skyblockz skyblockz commented Feb 19, 2020

dis.gd/status
Other than that 50k ping is api misbehavior
For me discord is sending g empty websocket, it should be back soon

@BudgetCode

This comment has been minimized.

Copy link

@BudgetCode BudgetCode commented Feb 19, 2020

It might be due to the key value not being cased correctly.

@NotSoSuper

This comment has been minimized.

Copy link

@NotSoSuper NotSoSuper commented Feb 19, 2020

Had this issue yesterday, a few thousand errors..

@nekokatt

This comment has been minimized.

Copy link
Author

@nekokatt nekokatt commented Feb 19, 2020

It might be due to the key value not being cased correctly.

I can't speak for aiohttp, but most sane HTTP implementations tend to use a tree map for HTTP headers with a case insensitive comparator. I know there is no treeset primitive in python, but aiohttp.typedefs.LooseHeaders should provide this functionality I would hope, so case sensitivity in HTTP headers should be ignored

@Dimbreath

This comment has been minimized.

Copy link
Contributor

@Dimbreath Dimbreath commented Feb 21, 2020

I can confirm this happens (and quite a lot recently) on 1.3.0.

@Moooog

This comment has been minimized.

Copy link

@Moooog Moooog commented Feb 22, 2020

happend to me earlier and some other people.

@Moooog

This comment has been minimized.

Copy link

@Moooog Moooog commented Feb 22, 2020

Command raised an exception: KeyError: 'content-type'

@Rapptz Rapptz closed this in 00f6562 Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.