Skip to content

Commit

Permalink
fix: proper errtrace fix (#4068)
Browse files Browse the repository at this point in the history
Errors were not being unwrapper properly
  • Loading branch information
stuartwdouglas authored Jan 16, 2025
1 parent 7d4a197 commit 549e68d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions common/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

// UnwrapAll recursively unwraps all errors in err, including all intermediate errors.
// Parent errors will always be ahead of errors they are wrapping in the resulting slice
//
//nolint:errorlint
func UnwrapAll(err error) []error {
Expand All @@ -18,10 +19,10 @@ func UnwrapAll(err error) []error {
}
return out
}
out = append(out, err)
if inner, ok := err.(interface{ Unwrap() error }); ok && inner.Unwrap() != nil {
out = append(out, UnwrapAll(inner.Unwrap())...)
}
out = append(out, err)
return out
}

Expand All @@ -38,15 +39,15 @@ func Innermost(err error) bool {
return true
}

func Join(errs ...error) error { return errors.Join(errs...) } //errtrace:skip // errtraces messes up error reporting
func Join(errs ...error) error { return errors.Join(errs...) }

func New(text string) error { return errors.New(text) }

func As(err error, target interface{}) bool { return errors.As(err, target) }

func Is(err, target error) bool { return errors.Is(err, target) }

func Unwrap(err error) error { return errors.Unwrap(err) } //errtrace:skip // errtraces messes up error reporting
func Unwrap(err error) error { return errors.Unwrap(err) }

// DeduplicateErrors de-duplicates equivalent errors.
func DeduplicateErrors(merr []error) []error {
Expand Down
2 changes: 1 addition & 1 deletion internal/authn/authn.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func checkAuth(ctx context.Context, logger *log.Logger, endpoint *url.URL, creds
client := &http.Client{
Timeout: time.Second * 5,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse //errtrace:skip(the HTTP client doesn't handle wrapping errors)
return http.ErrUseLastResponse
},
}
req, err := http.NewRequestWithContext(ctx, http.MethodHead, endpoint.String(), nil)
Expand Down
2 changes: 1 addition & 1 deletion internal/buildengine/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func handleBuildResult(ctx context.Context, projectConfig projectconfig.Config,
}

if len(errs) > 0 {
return nil, nil, errors.Join(errs...) //errtrace:skip // errtraces messes up error reporting
return nil, nil, errors.Join(errs...)
}

logger.Infof("Module built (%.2fs)", time.Since(result.StartTime).Seconds())
Expand Down

0 comments on commit 549e68d

Please sign in to comment.