Skip to content

🐛 [client] Fix update error propagation #126

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

Conversation

matthiasgeihs
Copy link
Contributor

Fixes a bug where updateGeneric discarded a PeerRejectedError and replaced it with a different error.

Signed-off-by: Matthias Geihs matthias@perun.network

client/update.go Outdated
Comment on lines 224 to 225
err = errors.WithMessagef(derr,
"progressing update failed: %v, then discarding update failed", updateErr)

Choose a reason for hiding this comment

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

Suggested change
err = errors.WithMessagef(derr,
"progressing update failed: %v, then discarding update failed", updateErr)
if derr == nil {
return err
}
return errors.WithMessagef(updateErr, "progressing update failed, then discarding update failed", derr)

In it's current form, when derr is nil, errors.WithMessagef will also return a nil. So updateErr will be missed even if it is not nil.

Separated into two returns because, when derr is nil, the phrase "then discarding update failed" will be confusing.

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

derr cannot be nil there because ; derr != nil {

Choose a reason for hiding this comment

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

Sorry, i missed that part. Then, it can be as it was before.

However, I think you may have to do errors.Messagef(updateErr.. instead of errors.Messagef(derr.. Because if only the message of updateErr is included, I think it cannot be retrieved later using errors.As.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Changing the ordering seemed unclean. Instead I do according to your first suggestion, don't change the error, just log derr. Please have a look.

@matthiasgeihs matthiasgeihs force-pushed the 125-update-error-propagation branch 2 times, most recently from e436c02 to 015cea1 Compare June 30, 2021 19:32
@manoranjith
Copy link

LGTM. You will have to rebase to latest dev and then I can approve it.

Fixes a bug where `updateGeneric` discarded a `PeerRejectedError` and replaced it with a different error.

Signed-off-by: Matthias Geihs <matthias@perun.network>
@matthiasgeihs matthiasgeihs force-pushed the 125-update-error-propagation branch from 015cea1 to 431fed6 Compare June 30, 2021 19:38
@manoranjith manoranjith merged commit c1cbad0 into hyperledger-labs:dev Jun 30, 2021
@ggwpez ggwpez deleted the 125-update-error-propagation branch July 1, 2021 11:10
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.

2 participants