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

Fix reference messages not being fully deleted #910

Closed
wants to merge 1 commit into from

Conversation

davfsa
Copy link
Member

@davfsa davfsa commented Nov 21, 2021

Thanks to @norinorin for finding the bug and providing the patch!

The patch was submitted with explicit permission from them

Checklist

  • I have run nox and all the pipelines have passed.
  • I have made unittests according to the code I have added/modified/deleted.

Related issues

Closes #904

@davfsa davfsa added the bug Something isn't working label Nov 21, 2021
@davfsa davfsa force-pushed the task/fix-memory-leak branch from 04d24b2 to 9560ff5 Compare November 21, 2021 12:11
@davfsa davfsa enabled auto-merge (squash) November 21, 2021 12:11
referenced_message = message.object.referenced_message
if not referenced_message and message.object.message_reference and message.object.message_reference.id:
msg_id = message.object.message_reference.id
referenced_message = self._message_entries.get(msg_id) or self._referenced_messages.get(msg_id)
Copy link
Collaborator

@FasterSpeeding FasterSpeeding Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this actually fixes the issue, if a referenced message is cached when message.referenced_message is None then wouldn't that infer there's a case the update/set logic isn't accounting for (possibly to do with idk something funky like the referenced message being deleted and that not cascading to places where its being referenced (to give a random example)).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware if there are any other cases, but another way that I could think of to handle this particular case is to ensure that we're not overriding referenced_message's referenced_message since Discord gives us None.

if not referenced_message and message.object.message_reference and message.object.message_reference.id:
msg_id = message.object.message_reference.id
referenced_message = self._message_entries.get(msg_id) or self._referenced_messages.get(msg_id)

Copy link
Collaborator

@FasterSpeeding FasterSpeeding Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also you're not accounting for what kind of reference this is so for stuff like cross posts, channel follows, and pins adds where you'd have message_reference.id but not referenced_message so this could lead to other edge case bugs but i'm not bothered to check how this'd play out in those scenarios rn

@davfsa
Copy link
Member Author

davfsa commented Jan 1, 2022

Closed to let @norinorin re-open with their changes

@davfsa davfsa closed this Jan 1, 2022
auto-merge was automatically disabled January 1, 2022 15:33

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Referenced message entries exceed the max messages settings
3 participants