[PM-39992] Wipe IPC Crypto Session When Destination is Unreachable#1229
Conversation
🔍 SDK Breaking Change DetectionSDK Version:
Breaking change detection uses the build of the SDK from this branch, including any incompatibities pre-existing on or merged into this branch. Check the workflow logs to confirm. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1229 +/- ##
==========================================
+ Coverage 85.21% 85.31% +0.09%
==========================================
Files 471 471
Lines 64893 65085 +192
==========================================
+ Hits 55301 55525 +224
+ Misses 9592 9560 -32 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ad8a5c2 to
3c9a42a
Compare
🤖 Bitwarden Claude Code ReviewOverall Assessment: REQUEST CHANGES Reviewed the IPC error-classification refactor that replaces the binary Code Review Details
|
| // Every other recoverable send failure is still surfaced. | ||
| ErrorKind::Other => { | ||
| error!( | ||
| "Recoverable error sending message to {:?}: {:?}", | ||
| destination, e | ||
| ); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Details and fix
The comment says "Every other recoverable send failure is still surfaced," but the ErrorKind::Other arm only logs and then falls through to sessions.save(...) and Ok(()). The message was never delivered, yet send() returns Ok(()).
Previously the code used communication.send(...).map_err(...)?, so any send failure (including recoverable ones) propagated to the caller. This change silently converts recoverable transport-send failures into success.
It also makes the ErrorKind::Other branch in ipc_client.rs::send (the tracing::warn! + SendError::Other mapping) unreachable for transport-send errors, since they no longer escape this function.
If the intent is to surface it (matching the sibling Fatal/Unreachable arms and the comment), add the missing return:
ErrorKind::Other => {
error!(
"Recoverable error sending message to {:?}: {:?}",
destination, e
);
return Err(e);
}If swallowing is intentional, the comment should be corrected and the ipc_client.rs Other handling reconciled.
eligrubb
left a comment
There was a problem hiding this comment.
Looks good! enum > bool, always.
…PC Crypto Session When Destination is Unreachable (bitwarden/sdk-internal#1229)
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-39992
Related clients PR: bitwarden/clients#21653
📔 Objective
Currently there is a few bugs around disconnects with the IPC layer. For the crypto layer, if one side disconnects, and then comes back with a fresh crypto state, the first message will be dropped. Subsequently, a re-establishment of the session will happen. We do not want the first message to be dropped because this already leads to some breakages of the intended use-cases. Namely, downstream in the clients layer, the connection confirms the connect worked correctly by starting a version request. Currently, this fails every time after a restart of the desktop app, because of the above issue.
There are a few ways to fix this. In this PR the fix chose is to propagate through the unreachability error throughout the SDK. The transport layer can elect to inform the SDK that the destination is unreachable. In this case, the SDK crypto layer will discard the crypto session. The next time the destination is available again, a new handshake will happen.
This also prevents stale crypto sessions from sticking around forever.
The PR provides a test case for the above scenario.
🚨 Breaking Changes