-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
feat: replace multierror with stdlib errors wrapping #41043
base: main
Are you sure you want to change the base?
Conversation
replace multierror library with stdlib error wrapping
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
@kruskall can we also remove the use of "github.com/pkg/errors"? |
Pinging @elastic/sec-windows-platform (Team:Security-Windows Platform) |
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
Pinging @elastic/sec-linux-platform (Team:Security-Linux Platform) |
This pull request is now in conflicts. Could you fix it? 🙏
|
That's not possible:
|
err.SetKey(convMap.Key + "." + err.Key()) | ||
_, errs := convMap.Schema.ApplyTo(subEvent, subData.(map[string]interface{})) | ||
for _, err := range errs { | ||
var keyErr schema.KeyError |
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 is surprising. It would be made less so if there were a comment explaining that while schema.KeyError
doesn't satisfy error
, its implementations do.
@@ -536,7 +536,7 @@ func TestFieldConcat(t *testing.T) { | |||
{Name: "foo", Fields: Fields{{Name: "b", Fields: Fields{{Name: "c"}}}}}, | |||
}, | |||
|
|||
err: "2 errors: fields contain key <a>; fields contain non object node conflicting with key <foo.b.c>", | |||
err: "fields contain key <a>\nfields contain non object node conflicting with key <foo.b.c>", |
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 was wondering about this. How does this impact on error rendering to users? I suspect it would be and improvement, but it's worth checking.
// reloadInputs wraps the multierror so we have to call Unwrap | ||
wr := errors.Unwrap(err) | ||
|
||
//nolint:errorlint // ignore |
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.
What is it complaining about here?
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
@@ -108,8 +108,7 @@ func (lo *IPv6Loopback) AddRandomAddress() (addr net.IP, err error) { | |||
if err = unix.Bind(fd, &bindAddr); err == nil { | |||
break | |||
} | |||
//nolint:errorlint // ignore | |||
if errno, ok := err.(unix.Errno); !ok || errno != unix.EADDRNOTAVAIL { | |||
if !errors.Is(err, unix.EADDRNOTAVAIL) { |
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.
:old-man-shouting-at-clouds: x/sys/unix has two instances of %w (both in code generators rather than lib code) and AFAICS no other form of error wrapping (it would be very strange if a package that sits at this level of the stack did). While not bound by go1compat or semver, it would be extremely surprising if this ever changed since code is copied from x/sys/unix into the std tree. But if it keeps people happy…
Proposed commit message
replace multierror library with stdlib error wrapping
Go 1.20 added errors.Join allowing for multierrors. Replace go-multierror usage with native go errors
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Disruptive User Impact
Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs