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: crash when self user is mentioned multiple times in last message [WPB-15157] 🍒 #3224

Conversation

saleniuk
Copy link
Contributor

@saleniuk saleniuk commented Jan 13, 2025

BugWPB-15157 App crashes after receiving links in a group chat

This PR was manually cherry-picked based on the following PR:

Original PR description:


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

When self user receives a message in which he/she is mentioned more than once, the app crashes as long as this message is the last one for the given conversation:
java.lang.IllegalArgumentException: Key "[email protected]" was already used

Causes (Optional)

When making a query, we left-join MessageMention with self_user_id or null if there are no mentions in last message for self user, however, this table has primary key consisting of not only message_id and conversation_id which means that there can be more than one mention in a given last message, moreover - self user can be mentioned more than once and that's what happens - self user has two mentions in last conversation message and then left-join creates two rows for the given conversation with both mentions.

Solutions

Count self user mentions and group results by conversation_id so that we're sure that there will only be a single row for each conversation.
When I was analysing and making tests of different approaches to find optimal one back then (#3098) I also noticed that having group by conversation_id doesn't affect the execution time, so it should be safe to use that.


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@echoes-hq echoes-hq bot added the echoes: unplanned Any work item that isn’t part of the product or technical roadmap. label Jan 13, 2025
Copy link
Contributor

github-actions bot commented Jan 13, 2025

Test Results

3 347 tests  ±0   3 239 ✅ ±0   5m 27s ⏱️ -38s
  572 suites ±0     108 💤 ±0 
  572 files   ±0       0 ❌ ±0 

Results for commit 8ef8368. ± Comparison against base commit 00bc08e.

♻️ This comment has been updated with latest results.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.51%. Comparing base (00bc08e) to head (8ef8368).

Additional details and impacted files
@@                Coverage Diff                 @@
##           release/candidate    #3224   +/-   ##
==================================================
  Coverage              54.50%   54.51%           
==================================================
  Files                   1250     1250           
  Lines                  36524    36524           
  Branches                3696     3696           
==================================================
+ Hits                   19909    19911    +2     
+ Misses                 15217    15215    -2     
  Partials                1398     1398           

see 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00bc08e...8ef8368. Read the comment docs.

@datadog-wireapp
Copy link

Datadog Report

Branch report: fix/multiple-self-mentions-in-last-message-crash-rc
Commit report: 32a944b
Test service: kalium-jvm

✅ 0 Failed, 3239 Passed, 108 Skipped, 1m 0.76s Total Time

@saleniuk saleniuk requested review from a team, yamilmedina, alexandreferris, vitorhugods, ohassine and mathias-niboulies and removed request for a team January 13, 2025 12:00
@echoes-hq echoes-hq bot added echoes: product-roadmap/bug Work contributing to resolve a bug not critical enough to have raised an incident. and removed echoes: unplanned Any work item that isn’t part of the product or technical roadmap. labels Jan 13, 2025
@saleniuk saleniuk added this pull request to the merge queue Jan 20, 2025
Merged via the queue into release/candidate with commit ff16a2c Jan 20, 2025
22 checks passed
@saleniuk saleniuk deleted the fix/multiple-self-mentions-in-last-message-crash-rc branch January 20, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: product-roadmap/bug Work contributing to resolve a bug not critical enough to have raised an incident. 👕 size: S type: bug / fix 🐞
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants