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

hot fix unwrap withink cli id-graph-hash #2697

Closed
wants to merge 1 commit into from

Conversation

BillyWooo
Copy link
Collaborator

as title. a small fix.

@BillyWooo BillyWooo requested a review from a team April 29, 2024 18:41
@Kailai-Wang
Copy link
Collaborator

I'm fine with it but if we want to do this, we probably need to do it for all CLI commands.
Normally CLI isn't that critical as it's not part of runtime - so unwrap = CLI program exit (which is fine)

@@ -36,8 +36,14 @@ impl IDGraphHashCommand {
let mrenclave = direct_api.get_state_mrenclave().unwrap();
let shard = ShardIdentifier::decode(&mut &mrenclave[..]).unwrap();
let identity = Identity::from_did(self.did.as_str()).unwrap();
let id_graph_hash = direct_api.get_id_graph_hash(&shard, &identity).unwrap();
println!("{:?}", id_graph_hash);
match direct_api.get_id_graph_hash(&shard, &identity) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not expect ?
It can panic with more friendly message, additionaly Ok is not returned (there was a failure).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What Ok is not returned?

Copy link
Member

Choose a reason for hiding this comment

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

unwrap previously prevented from returning Ok from function.
After you fix, even if there is an error the function will return Ok

@BillyWooo
Copy link
Collaborator Author

The reason I want to add it is: I need to do a group of id-graph-hash ops. If it simply crashes, it's hard to be managed within scripts.
I will put this on hold and discuss later whether to check all cli commands.

@BillyWooo BillyWooo marked this pull request as draft April 30, 2024 08:21
@BillyWooo
Copy link
Collaborator Author

close for the moment.
P-755 : take care of crash/panic from cli tools/commands

@BillyWooo BillyWooo closed this May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants