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(proteus): prevent missing messages by using transactions [WPB-10873] 🍒 #3007

Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 12, 2024

BugWPB-10873 Version 4.8 does not deliver all attachments in a group chat

This PR was automatically 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

Some clients reported missing messages.
We found that it is not that hard to kill the app by swiping it away between decryption and DB insertion.

Solutions

  • CoreCrypto doesn't support transactions yet: every decrypt persist state and if the app dies after decrypting, the message is forever gone.
  • CryptoBox does to some degree. It doesn't support rolling back a transaction gracefully. It requires recreating a CoreCrypto instance using the same files. So we can at least simulate app killing by recreating this.

By not saving the session before inserting the messages into the DB, we can try to process this event again and recover this message.

Changed the API so instead of returning ByteArray, the Proteus clients will accept a lambda to process the output.
After allowing processing the output, the Proteus clients will persist the session.
CoreCrypto (that doesn't support saving session later) will decrypt and call the lambda normally.

Testing

Test Coverage

  • I have added automated test to this contribution

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: unplanned Any work item that isn’t part of the product or technical roadmap. type: bug / fix 🐞 👕 size: L labels Sep 12, 2024
@@ -68,6 +74,7 @@ internal class ProteusMessageUnpackerImpl(
return proteusClientProvider.getOrError()
.flatMap {
wrapProteusRequest {
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

:(

@vitorhugods vitorhugods force-pushed the fix/proteus/use-transactions-for-cryptobox-cherry-pick branch from 6b5c610 to e617029 Compare September 18, 2024 12:33
Copy link

Copy link
Contributor Author

github-actions bot commented Sep 18, 2024

Test Results

3 206 tests  +2   3 099 ✔️ ±0   4m 1s ⏱️ +33s
   551 suites ±0      107 💤 +2 
   551 files   ±0          0 ±0 

Results for commit e617029. ± Comparison against base commit 582e546.

♻️ This comment has been updated with latest results.

@MohamadJaara MohamadJaara added this pull request to the merge queue Sep 18, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 68.11594% with 22 lines in your changes missing coverage. Please review.

Project coverage is 52.55%. Comparing base (582e546) to head (e617029).

Files with missing lines Patch % Lines
...ver/conversation/message/ProteusMessageUnpacker.kt 40.62% 19 Missing ⚠️
...kalium/cryptography/ProteusClientCoreCryptoImpl.kt 71.42% 2 Missing ⚠️
...ver/conversation/message/NewMessageEventHandler.kt 96.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3007   +/-   ##
========================================
  Coverage    52.54%   52.55%           
========================================
  Files         1301     1301           
  Lines        50059    50066    +7     
  Branches      4666     4665    -1     
========================================
+ Hits         26304    26310    +6     
- Misses       21880    21883    +3     
+ Partials      1875     1873    -2     
Files with missing lines Coverage Δ
...tlin/com/wire/kalium/cryptography/ProteusClient.kt 87.50% <ø> (ø)
...ver/conversation/message/NewMessageEventHandler.kt 83.49% <96.66%> (+1.94%) ⬆️
...kalium/cryptography/ProteusClientCoreCryptoImpl.kt 44.66% <71.42%> (+0.54%) ⬆️
...ver/conversation/message/ProteusMessageUnpacker.kt 60.93% <40.62%> (-4.58%) ⬇️

... and 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 582e546...e617029. Read the comment docs.

@MohamadJaara MohamadJaara removed this pull request from the merge queue due to a manual request Sep 18, 2024
@MohamadJaara MohamadJaara added this pull request to the merge queue Sep 18, 2024
@datadog-wireapp
Copy link

Datadog Report

Branch report: fix/proteus/use-transactions-for-cryptobox-cherry-pick
Commit report: c691be4
Test service: kalium-jvm

✅ 0 Failed, 3099 Passed, 107 Skipped, 12.27s Total Time

Merged via the queue into develop with commit 3e6a84f Sep 18, 2024
21 of 22 checks passed
@MohamadJaara MohamadJaara deleted the fix/proteus/use-transactions-for-cryptobox-cherry-pick branch September 18, 2024 13:23
MohamadJaara pushed a commit that referenced this pull request Oct 18, 2024
…73] 🍒 (#3007)

* Commit with unresolved merge conflicts

* chore: solve conflicts

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>
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: unplanned Any work item that isn’t part of the product or technical roadmap. 👕 size: L type: bug / fix 🐞
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants