question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

THREAD_MEMBERS_UPDATE causes a KeyError

See original GitHub issue

Summary

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.

image 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:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dolfiescommented, Jan 22, 2022

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.

1reaction
dolfiescommented, Jan 19, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found