THREAD_MEMBERS_UPDATE causes a KeyError
See original GitHub issueSummary
KeyError: ‘member’ when running code for extended period of time.
Reproduction Steps
Unsure how to reproduce.
Traceback (most recent call last):
File "/root/code/MCStalker/gungyDataStealer/main.py", line 286, in <module>
bot.run("almost pasted my token *again*")
File "/root/code/MCStalker/gungyDataStealer/discord/client.py", line 654, in run
return future.result()
File "/root/code/MCStalker/gungyDataStealer/discord/client.py", line 633, in runner
await self.start(*args, **kwargs)
File "/root/code/MCStalker/gungyDataStealer/discord/client.py", line 597, in start
await self.connect(reconnect=reconnect)
File "/root/code/MCStalker/gungyDataStealer/discord/client.py", line 510, in connect
await self.ws.poll_event()
File "/root/code/MCStalker/gungyDataStealer/discord/gateway.py", line 561, in poll_event
await self.received_message(msg.data)
File "/root/code/MCStalker/gungyDataStealer/discord/gateway.py", line 511, in received_message
func(data)
File "/root/code/MCStalker/gungyDataStealer/discord/state.py", line 1154, in parse_thread_members_update
added_members = [ThreadMember(thread, d) for d in data.get('added_members', [])]
File "/root/code/MCStalker/gungyDataStealer/discord/state.py", line 1154, in <listcomp>
added_members = [ThreadMember(thread, d) for d in data.get('added_members', [])]
File "/root/code/MCStalker/gungyDataStealer/discord/threads.py", line 767, in __init__
self._from_data(data)
File "/root/code/MCStalker/gungyDataStealer/discord/threads.py", line 791, in _from_data
mdata = data['member']
KeyError: 'member'
There are no threads in my server, at all. No one made a thread, I’m not sure why there’s an error in threads.py.
Issue seems to be here in threads.py. I left my code running overnight and the error happened relatively early (an hour in).
Code
No response
Expected Results
Code supposed to run for extended periods of time without erroring.
Actual Results
Code errors for unknown reason at random times.
System Information
discord.py is a requirement, which is a library I don’t plan on installing.
Checklist
- I have searched the open issues for duplicates.
- I have shared the entire traceback.
- I am using a user token (and it isn’t visible in the code).
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
KeyError in module 'threading' after a successful py.test run
It seems like the problem is coming from the main loop terminating before the background thread has the ability to finish what it's...
Read more >How to Fix KeyError Exceptions in Python - Rollbar
The Python KeyError is an exception that occurs when an attempt is made to access an item in a dictionary that does not...
Read more >Python KeyError Exceptions and How to Handle Them
In this tutorial, you'll learn how to handle Python KeyError exceptions. They are often caused by a bad key lookup in a dictionary,...
Read more >dimscord/objects
CacheError = object of KeyError ... thread_members_update*: proc (s: Shard; e: ThreadMembersUpdate) {.async.} stage_instance_create*: proc (s: Shard; ...
Read more >Exception KeyError in module threading - Google Groups
I have a Django app running that *appears* to work fine (from a user's perspective). But the error_log is constantly filled with these...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was a little busy the past few days, but I’ll work on it today. The fix isn’t as easy as I thought because thread events (specifically create/join) are slightly broken and I need to fix those too.
Loons like they made the member key a member object instead of a dict that holds a member and presence object. Pretty easy fix. I’ll commit later in the day.