Skip to content

fix(err-prop): status code propagation (attempt 2) #17962

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

owen-d
Copy link
Member

@owen-d owen-d commented Jun 4, 2025

Fix error handling for MultiError with new Unwrap() method

This PR supersedes a previous approach (#17950) which implements error code propagation across sharded subqueries more effectively by supporting the Unwrap() method. Doing so unfortunately also broke the handling of pkg/util/server.ClientHTTPStatusAndError, which I refactored to account for this (some of the expected test logic felt a bit funky, but I ensured my refactor matched the current testware expectations nonetheless).

Changes

1. Enhanced MultiError (pkg/util/errors.go)

  • Added Unwrap() []error method to enable errors.{As,Is}() functionality

2. Updated retry logic (pkg/querier/queryrange/queryrangebase/retry.go)

  • Replaced grpcutil.ErrorToStatusCode() with grpcutil.ErrorToStatus() which accesses embedded errors

3. Fixed error handling (pkg/util/server/error.go) to account for MultiError implementing Unwrap() and therefore being able to enumerate values inside an error chain

@owen-d owen-d requested a review from a team as a code owner June 4, 2025 00:45
@@ -96,7 +96,12 @@ func (r retry) Do(ctx context.Context, req Request) (Response, error) {
return nil, ctx.Err()
}

code := grpcutil.ErrorToStatusCode(err)
var code int
st, ok := grpcutil.ErrorToStatus(err)
Copy link
Member Author

Choose a reason for hiding this comment

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

the grpcutil (dskit) variant respects Unwrap to read the underlying errors more naturally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 participant