-
Notifications
You must be signed in to change notification settings - Fork 78
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
app/eth2wrap: fix error comparison for synthetic blocks #2702
Conversation
@@ -330,7 +330,7 @@ func incError(endpoint string) { | |||
// wrapError returns the error as a wrapped structured error. | |||
func wrapError(ctx context.Context, err error, label string, fields ...z.Field) error { | |||
// Decompose go-eth2-client http errors | |||
if apiErr := new(eth2api.Error); errors.As(err, apiErr) { | |||
if apiErr := new(eth2api.Error); errors.As(err, &apiErr) { |
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.
Seems like this was not working at all until now :(
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.
There must be a linter somewhere that checks for this...
if apiErr.StatusCode == http.StatusNotFound { | ||
continue | ||
} | ||
if fieldExists(err, zap.Int("status_code", http.StatusNotFound)) { |
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.
This was needed as the returned error will be a wrapped error from eth2wrap.Multi struct
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2702 +/- ##
==========================================
+ Coverage 53.19% 53.47% +0.27%
==========================================
Files 201 201
Lines 27596 27615 +19
==========================================
+ Hits 14679 14766 +87
+ Misses 11099 11032 -67
+ Partials 1818 1817 -1
☔ View full report in Codecov by Sentry. |
SonarCloud Quality Gate failed. 0 Bugs No Coverage information Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
@@ -204,6 +204,34 @@ func (h *synthWrapper) syntheticProposal(ctx context.Context, slot eth2p0.Slot, | |||
return proposal, nil | |||
} | |||
|
|||
// fieldExists checks if the given field exists as part of the given error. | |||
func fieldExists(err error, field zap.Field) bool { |
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 wonder if instead of declaring this function here, we should create a z.Fields()
function that returns []z.Field
.
The casting logic seems to be a 1:1 copy off z.Err
.
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.
Approving and opening an issue to later address https://github.com/ObolNetwork/charon/pull/2702/files#r1389222292
There was a small issue when comparing eth2api errors when searching for signed beacon block. The error returned should be part of eth2wrap multi implementation which was not able to decompose eth2 errors properly. This PR fixes decomposition of eth2 errors and adds a function to check if the relevant field is present as part of the error chain. category: bug ticket: #2695
This PR cherry-picks #2702 onto `main-v0.18` --- There was a small issue when comparing eth2api errors when searching for signed beacon block. The error returned should be part of eth2wrap multi implementation which was not able to decompose eth2 errors properly. This PR fixes decomposition of eth2 errors and adds a function to check if the relevant field is present as part of the error chain. category: bug ticket: #2695
There was a small issue when comparing eth2api errors when searching for signed beacon block. The error returned should be part of eth2wrap multi implementation which was not able to decompose eth2 errors properly. This PR fixes decomposition of eth2 errors and adds a function to check if the relevant field is present as part of the error chain.
category: bug
ticket: #2695