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] 🍒 🍒 #3234

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jan 20, 2025

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

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

Original PR description:


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.

@github-actions github-actions bot added cherry-pick PR is cherry-picking changes from another banch echoes: product-roadmap/bug Work contributing to resolve a bug not critical enough to have raised an incident. type: bug / fix 🐞 👕 size: S labels Jan 20, 2025
@saleniuk saleniuk requested review from a team, yamilmedina, alexandreferris, MohamadJaara, saleniuk and mathias-niboulies and removed request for a team January 21, 2025 10:29
Copy link
Contributor Author

github-actions bot commented Jan 21, 2025

Test Results

3 405 tests  ±0   3 297 ✅ ±0   5m 49s ⏱️ +7s
  584 suites ±0     108 💤 ±0 
  584 files   ±0       0 ❌ ±0 

Results for commit 0b13b14. ± Comparison against base commit 01522be.

♻️ This comment has been updated with latest results.

Copy link
Contributor Author

github-actions bot commented Jan 21, 2025

@datadog-wireapp
Copy link

datadog-wireapp bot commented Jan 21, 2025

Datadog Report

Branch report: fix/multiple-self-mentions-in-last-message-crash-rc-cherry-pick
Commit report: 11b116a
Test service: kalium-jvm

✅ 0 Failed, 3297 Passed, 108 Skipped, 1m 1.4s Total Time

@codecov-commenter
Copy link

codecov-commenter commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.44%. Comparing base (01522be) to head (0b13b14).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3234      +/-   ##
===========================================
- Coverage    54.44%   54.44%   -0.01%     
===========================================
  Files         1271     1271              
  Lines        37018    37018              
  Branches      3753     3753              
===========================================
- Hits         20156    20154       -2     
- Misses       15445    15447       +2     
  Partials      1417     1417              

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 01522be...0b13b14. Read the comment docs.

@saleniuk
Copy link
Contributor

saleniuk commented Jan 21, 2025

In order to keep migrations order between RC (4.10) and dev (4.11), migrations that appear only in dev were moved forward so that the one added by this fix for RC (#3238) is in right place and all of them are in correct order:

  • 95.sqm is moved to 97.sqm
  • 96.sqm is moved to 98.sqm
  • the one provided with this fix is added as 95.sqm, just like in RC
  • the added one 96.sqm from fix for RC is also added here to dev as 96.sqm, just like in RC

@saleniuk saleniuk added this pull request to the merge queue Jan 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 22, 2025
@saleniuk saleniuk added this pull request to the merge queue Jan 22, 2025
Merged via the queue into develop with commit c6d3335 Jan 22, 2025
23 checks passed
@saleniuk saleniuk deleted the fix/multiple-self-mentions-in-last-message-crash-rc-cherry-pick branch January 22, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick PR is cherry-picking changes from another banch echoes: product-roadmap/bug Work contributing to resolve a bug not critical enough to have raised an incident. 👕 size: L type: bug / fix 🐞
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants