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

bugfix: model: Avoid creating empty messages from reaction events. #1162

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

neiljp
Copy link
Collaborator

@neiljp neiljp commented Mar 11, 2022

What does this PR do?

This updates an approach taken in the original reaction implementation.

Since locally cached messages are currently stored in a defaultdict,
direct indexing with a non-present message-id creates an empty message.
Such messages then generate KeyErrors when flags are updated later
(eg. marking read, toggling star status), if the message has not been
fetched.

Tests updated to explicitly exclude generation of empty index for
reaction events.

Fixes #920.

Tested?

  • Manually
  • Existing tests (adapted, if necessary)
  • Passed linting & tests (each commit)

Notes & Questions

This suggests we should move away from defaultdict for at least this data structure, as access masks generation of invalid data.

Interactions

This is purely a bugfix. This prompts thoughts on further refactoring, but an outstanding branch for improving reaction handling may conflict with that, so this is left for now.

This updates an approach taken in the original reaction implementation.

Since locally cached messages are currently stored in a `defaultdict`,
direct indexing with a non-present message-id creates an empty message.
Such messages then generate `KeyError`s when flags are updated later
(eg. marking read, toggling star status), if the message has not been
fetched.

Tests updated to explicitly exclude generation of empty index for
reaction events.

Fixes zulip#920.
@neiljp neiljp added bug Something isn't working high priority should be done as soon as possible labels Mar 11, 2022
@neiljp neiljp added this to the Next Release milestone Mar 11, 2022
@zulipbot zulipbot added the size: S [Automatic label added by zulipbot] label Mar 11, 2022
@neiljp neiljp merged commit 85b2d50 into zulip:main Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority should be done as soon as possible size: S [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KeyError: 'flags'
2 participants