-
Notifications
You must be signed in to change notification settings - Fork 269
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
chore(crypto): Add consistency check on device when loading account #4564
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4564 +/- ##
==========================================
+ Coverage 85.40% 85.41% +0.01%
==========================================
Files 285 285
Lines 32218 32221 +3
==========================================
+ Hits 27515 27521 +6
+ Misses 4703 4700 -3 ☔ View full report in Codecov by Sentry. |
/// An account was saved but no own device was found. | ||
#[error("Incomplete account, account data was saved but no own device was found")] | ||
IncompleteAccountNoOwnDevice, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not enthusiastic about adding this here as yet another error code that any API can return: error handling is really hard when you call matrix-sdk-crypto APIs because there are thousands of possible error cases.
Maybe we can specialise the result from with_store
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I was not sure about this one. What do you mean by "specialise" the result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it return a different error type in its Result, which more closely reflects the actual possible failure modes of that particular method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking request changes for Rich's comment, which I agree with.
Add a consistency check when loading an account from a store.
When creating an olm machine for an empty store, the own device is explicitely saved before the account (and it is done on purpose before the initial
keys/query
response):matrix-rust-sdk/crates/matrix-sdk-crypto/src/machine/mod.rs
Lines 328 to 340 in 210c574
However when loading an existing account we don't check for the existence of this own device.
There are other part in the code when we expect the own device to always exists:
matrix-rust-sdk/crates/matrix-sdk-sqlite/src/crypto_store.rs
Line 1205 in 210c574
Let's do the consistency check as soon as possible to avoid future strange states.
Signed-off-by: