-
Notifications
You must be signed in to change notification settings - Fork 358
Create a separate error variant to indicate a failure importing a secret. #5647
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
df5ba0b
log errors from get_secret
uhoreg 00de190
create a separate error variant to indicate a failure to import a secret
uhoreg 71dc404
fixup! add a missed case
uhoreg 958d0dc
add tests
uhoreg 0cb753f
fixup! switch from if statement to match statement
uhoreg 6d8b3da
add secret name to import error
uhoreg fbf8b45
add changelog
uhoreg d227f74
Merge branch 'main' into separate_import_error
uhoreg 2bb4707
convert to using global_account_data_mock_builder
uhoreg 083f575
fixup! convert to using global_account_data_mock_builder
uhoreg c3ea78e
fixup! convert to using global_account_data_mock_builder
uhoreg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry for the drive-by comment, but don't we want to remember which secret couldn't have been imported?
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.
It wasn't needed for the issue I was working on, but it does sound like it could be useful. I guess it means that I can't just use
ImportError::from(or I can't just use the automatic conversion fromImportErrortoSecretStorageError. Is there some sort of convention that I should follow?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.
You won't be able to use the automatic conversion, but you can just
map_err()from one error to the other and include the context that we can't infer automatically this way.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.
Sorry, I wasn't clear with my question. I was wondering if there was a convention for what to put in the
map_err. Should I just throw an anonymous function in there? Or should I pre-define some functions inImportError? Or something else?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.
Depends on how many times you need to do the same map, two or more use a pre-defined function, otherwise anonymous functions are fine.
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've changed SecretStorageError::ImportError to have
nameanderrorfields, wherenameis the name of the secret that was being imported. It all seems fine except that the waySecretStore.import_secretsimports the cross signing keys is that it loads all the secrets from Secret Storage (which is fine, it callsSecretStore.get_secretindividually on each secret name), but then it bundles them all up and callsOlmMachine.import_cross_signing_keyson the whole bundle. In there, it will error, for example, if one of the private keys doesn't match the public key.But that means that I can't tell which secret caused the error, unless I modify the error type returned by
OlmMachine.import_cross_signing_keysso that it contains the secret name, which means changing stuff in the crypto crate. I'm a bit hesitant to go deeper into the Rust SDK for this, since it will probably affect more stuff, but I think it's the only way to get the right information. So, just wanted to double check that it's OK for me to do that.I think the alternative would be to hard-code something in
SecretStore.import_secretssaying that it's, say, the Master key that caused the error, and hope for the best, but I'm not too excited about that either.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 think it's fine to include that in the crypto crate as well. Sure that's a breaking change but a fairly minor one.