From 4d13ddf6b31ceb1b76d24cfa96808a7eabb57555 Mon Sep 17 00:00:00 2001 From: Poorna Date: Tue, 29 Mar 2022 10:53:09 -0700 Subject: [PATCH] Avoid shadowing error during replication proxy check (#14655) Fixes #14652 --- cmd/object-handlers.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 44a5b2326..ecf82fe30 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -416,16 +416,17 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj var ( reader *GetObjectReader proxy proxyResult + perr error ) proxytgts := getproxyTargets(ctx, bucket, object, opts) if !proxytgts.Empty() { // proxy to replication target if active-active replication is in place. - reader, proxy, err = proxyGetToReplicationTarget(ctx, bucket, object, rs, r.Header, opts, proxytgts) - if err != nil && !isErrObjectNotFound(ErrorRespToObjectError(err, bucket, object)) && - !isErrVersionNotFound(ErrorRespToObjectError(err, bucket, object)) { - logger.LogIf(ctx, fmt.Errorf("Replication proxy failed for %s/%s(%s) - %w", bucket, object, opts.VersionID, err)) + reader, proxy, perr = proxyGetToReplicationTarget(ctx, bucket, object, rs, r.Header, opts, proxytgts) + if perr != nil && !isErrObjectNotFound(ErrorRespToObjectError(perr, bucket, object)) && + !isErrVersionNotFound(ErrorRespToObjectError(perr, bucket, object)) { + logger.LogIf(ctx, fmt.Errorf("Replication proxy failed for %s/%s(%s) - %w", bucket, object, opts.VersionID, perr)) } - if reader != nil && proxy.Proxy && err == nil { + if reader != nil && proxy.Proxy && perr == nil { gr = reader } }