Repository: minio/minio (language: go)

Issue:
Error: Replication proxy failed for image/4.jpg() - At least one of the pre-conditions you specified did not hold (*fmt.wrapError)
## NOTE
If this case is urgent, please subscribe to [Subnet](https://min.io/pricing) so that our 24/7 support team may help you faster.

<!--- Provide a general summary of the issue in the Title above -->

## Current Behavior
I use Two-Way Server-Side Bucket Replication.Then I read one of the photo address two times.Actually I can see the picture, but the logs of minio has 12 identical errors.Errors like this.


## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->

## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
<!--- and make sure you have followed https://github.com/minio/minio/tree/release/docs/debugging to capture relevant logs -->

1.Deploy two minio services.
2.Create enableremote and enablereplication policies.
3.Create a user, set enableremote and enablereplication permissions.
4.Create image buckets on the two minios respectively, and use the MinIo Console to create replication rules.
5.Upload a picture, the two services are synchronized, access the picture link of one of them twice, the actual picture can be seen, but the minio log has an error.
6.Error:
API: GetObject
Time: Tue Jun 21 2022 01:59:34 GMT+0800 (中国标准时间)
DeploymentID: d6ded3f6-17e0-49a3-bdd8-61e12a1ad942
RequestID: 16FA803426C19DCB
RemoteHost: 192.168.1.133
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44
Error: Replication proxy failed for image/4.jpg() - At least one of the pre-conditions you specified did not hold (*fmt.wrapError)
Backtrace: 
0: internal/logger/logger.go:278:logger.LogIf()
1: cmd/object-handlers.go:434:cmd.objectAPIHandlers.getObjectHandler()
2: cmd/object-handlers.go:599:cmd.objectAPIHandlers.GetObjectHandler()
3: net/http/server.go:2084:http.HandlerFunc.ServeHTTP()


## Context
This problem results in hundreds of KB of logs per day.
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

## Regression
<!-- Is this issue a regression? (Yes / No) -->
<!-- If Yes, optionally please include minio version or commit id or PR# that caused this regression, if you have these details. -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used (`2022-06-11T19:55:32Z`):
* Server setup and configuration:Two sites, each site uses two servers and 4 drivers
* Operating System and version (`Linux localhost 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
`):



Discussion / hints:
Do you have encryption enabled on these sites? Can you run a http trace with `mc admin trace -v site-alias >  trace.log` on both sites before you upload the picture and stop the trace with ctrl-c afterwards and attach the trace logs here - would help with identifying the root cause.
Without encryption enabled, I visit http://192.168.3.48:9001/image/4.jpg
first site:
192.168.3.48:9001 [REQUEST s3.GetObject] [2022-06-21T14:26:16:000] [Client IP: 192.168.1.133]
192.168.3.48:9001 GET /image/4.jpg
192.168.3.48:9001 Proto: HTTP/1.1
192.168.3.48:9001 Host: 192.168.3.48:9001
192.168.3.48:9001 If-Modified-Since: Tue, 14 Jun 2022 09:08:48 GMT
192.168.3.48:9001 If-None-Match: "f3833a91e2597672b55e6be3178be22b"
192.168.3.48:9001 Cache-Control: max-age=0
192.168.3.48:9001 Accept-Encoding: gzip, deflate
192.168.3.48:9001 Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,und;q=0.5
192.168.3.48:9001 Connection: keep-alive
192.168.3.48:9001 Content-Length: 0
192.168.3.48:9001 Cookie: _ga=GA1.1.1249572035.1640053929; upwd=eyJuYW1lIjoieHVyb25nMjMzIiwicGFzc3dvcmQiOiJYcjIzMzY2Ni4ifQ==; token=AAv6FjCrgY1+kYvqY3NShwI2VKiYDVOEzJrTxc11TW+yYtXsUhXiAOyGMH/xfDyHRITU7xxDX1IGhbhrWKQCwDDLyz6khogti6cUtyn/OhffgELtgZm4o45qXShAz0c2AUo0JymI1YU3sk7ktc1GFg78MwFhALScDEN0TVn4m/8sNUNaoC7lk3Xu55XUD9q2SpztBpYkqjk53zpc1WOuBCcPW8oPGjrDpeJ3ZKoL47ftpAaixr77DAeOxYLj44LGdVKY1V9pL410qdZwJ4oAETIc57hZKkM5qf4XL4RmOFKtqcAdYtZqmZsGuuNzWs8R5Tu0Rv03m6+5jhnFII4zHR6sHC4UwbmC5uFgUhhHgy82eSELAXRAMdsOxXcTubcVZer4DyJTGYhKfVNPHBv0QkdsZ62XXD670fahplx0tfoy+azFL6EU1P5hMEKajLwQjivJQnLX1cA8fdz4m1qYumERaZKaGC6ccGy2vDRv4gdBC935EG0+5bKdApO/BvB4HqYs3zsMnWsrRoVwEIDTu/37K2fJHGTUpxCSG8BQkNE=
192.168.3.48:9001 Upgrade-Insecure-Requests: 1
192.168.3.48:9001 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
192.168.3.48:9001 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44
192.168.3.48:9001 <BODY>
192.168.3.48:9001 [RESPONSE] [2022-06-21T14:26:16:000] [ Duration 5.224ms  ↑ 160 B  ↓ 388 B ]
192.168.3.48:9001 304 Not Modified
192.168.3.48:9001 No-Gzip-Compression: true
192.168.3.48:9001 Strict-Transport-Security: max-age=31536000; includeSubDomains
192.168.3.48:9001 Vary: Origin,Accept-Encoding
192.168.3.48:9001 ETag: "f3833a91e2597672b55e6be3178be22b"
192.168.3.48:9001 Content-Security-Policy: block-all-mixed-content
192.168.3.48:9001 Last-Modified: Tue, 14 Jun 2022 09:08:48 GMT
192.168.3.48:9001 Server: MinIO
192.168.3.48:9001 X-Amz-Request-Id: 16FA8EC1E0C7C0C4
192.168.3.48:9001 X-Content-Type-Options: nosniff
192.168.3.48:9001 X-Xss-Protection: 1; mode=block
192.168.3.48:9001 Accept-Ranges: bytes
192.168.3.48:9001 <BODY>
192.168.3.48:9001 
192.168.3.48:9001 [REQUEST s3.ListObjectsV1] [2022-06-21T14:26:16:000] [Client IP: 192.168.1.133]
192.168.3.48:9001 GET /favicon.ico
192.168.3.48:9001 Proto: HTTP/1.1
192.168.3.48:9001 Host: 192.168.3.48:9001
[root@minio1 ~]# mc admin trace -v minio-server
192.168.3.48:9001 [REQUEST s3.GetObject] [2022-06-21T14:27:50:000] [Client IP: 192.168.1.133]
192.168.3.48:9001 GET /image/4.jpg
192.168.3.48:9001 Proto: HTTP/1.1
192.168.3.48:9001 Host: 192.168.3.48:9001
192.168.3.48:9001 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
192.168.3.48:9001 Cache-Control: max-age=0
192.168.3.48:9001 Connection: keep-alive
192.168.3.48:9001 If-None-Match: "f3833a91e2597672b55e6be3178be22b"
192.168.3.48:9001 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44
192.168.3.48:9001 If-Modified-Since: Tue, 14 Jun 2022 09:08:48 GMT
192.168.3.48:9001 Upgrade-Insecure-Requests: 1
192.168.3.48:9001 Accept-Encoding: gzip, deflate
192.168.3.48:9001 Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,und;q=0.5
192.168.3.48:9001 Content-Length: 0
192.168.3.48:9001 Cookie: _ga=GA1.1.1249572035.1640053929; upwd=eyJuYW1lIjoieHVyb25nMjMzIiwicGFzc3dvcmQiOiJYcjIzMzY2Ni4ifQ==; token=AAv6FjCrgY1+kYvqY3NShwI2VKiYDVOEzJrTxc11TW+yYtXsUhXiAOyGMH/xfDyHRITU7xxDX1IGhbhrWKQCwDDLyz6khogti6cUtyn/OhffgELtgZm4o45qXShAz0c2AUo0JymI1YU3sk7ktc1GFg78MwFhALScDEN0TVn4m/8sNUNaoC7lk3Xu55XUD9q2SpztBpYkqjk53zpc1WOuBCcPW8oPGjrDpeJ3ZKoL47ftpAaixr77DAeOxYLj44LGdVKY1V9pL410qdZwJ4oAETIc57hZKkM5qf4XL4RmOFKtqcAdYtZqmZsGuuNzWs8R5Tu0Rv03m6+5jhnFII4zHR6sHC4UwbmC5uFgUhhHgy82eSELAXRAMdsOxXcTubcVZer4DyJTGYhKfVNPHBv0QkdsZ62XXD670fahplx0tfoy+azFL6EU1P5hMEKajLwQjivJQnLX1cA8fdz4m1qYumERaZKaGC6ccGy2vDRv4gdBC935EG0+5bKdApO/BvB4HqYs3zsMnWsrRoVwEIDTu/37K2fJHGTUpxCSG8BQkNE=
192.168.3.48:9001 <BODY>
192.168.3.48:9001 [RESPONSE] [2022-06-21T14:27:50:000] [ Duration 6.14ms  ↑ 160 B  ↓ 388 B ]
192.168.3.48:9001 304 Not Modified
192.168.3.48:9001 Last-Modified: Tue, 14 Jun 2022 09:08:48 GMT
192.168.3.48:9001 No-Gzip-Compression: true
192.168.3.48:9001 Server: MinIO
192.168.3.48:9001 X-Content-Type-Options: nosniff
192.168.3.48:9001 X-Xss-Protection: 1; mode=block
192.168.3.48:9001 X-Amz-Request-Id: 16FA8ED7AE12B084
192.168.3.48:9001 Accept-Ranges: bytes
192.168.3.48:9001 Content-Security-Policy: block-all-mixed-content
192.168.3.48:9001 ETag: "f3833a91e2597672b55e6be3178be22b"
192.168.3.48:9001 Strict-Transport-Security: max-age=31536000; includeSubDomains
192.168.3.48:9001 Vary: Origin,Accept-Encoding
192.168.3.48:9001 <BODY>
192.168.3.48:9001 
192.168.3.48:9001 [REQUEST s3.ListObjectsV1] [2022-06-21T14:27:50:000] [Client IP: 192.168.1.133]
192.168.3.48:9001 GET /favicon.ico
192.168.3.48:9001 Proto: HTTP/1.1
192.168.3.48:9001 Host: 192.168.3.48:9001
192.168.3.48:9001 Accept: image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8
192.168.3.48:9001 Accept-Encoding: gzip, deflate
192.168.3.48:9001 Content-Length: 0
192.168.3.48:9001 Cookie: _ga=GA1.1.1249572035.1640053929; upwd=eyJuYW1lIjoieHVyb25nMjMzIiwicGFzc3dvcmQiOiJYcjIzMzY2Ni4ifQ==; token=AAv6FjCrgY1+kYvqY3NShwI2VKiYDVOEzJrTxc11TW+yYtXsUhXiAOyGMH/xfDyHRITU7xxDX1IGhbhrWKQCwDDLyz6khogti6cUtyn/OhffgELtgZm4o45qXShAz0c2AUo0JymI1YU3sk7ktc1GFg78MwFhALScDEN0TVn4m/8sNUNaoC7lk3Xu55XUD9q2SpztBpYkqjk53zpc1WOuBCcPW8oPGjrDpeJ3ZKoL47ftpAaixr77DAeOxYLj44LGdVKY1V9pL410qdZwJ4oAETIc57hZKkM5qf4XL4RmOFKtqcAdYtZqmZsGuuNzWs8R5Tu0Rv03m6+5jhnFII4zHR6sHC4UwbmC5uFgUhhHgy82eSELAXRAMdsOxXcTubcVZer4DyJTGYhKfVNPHBv0QkdsZ62XXD670fahplx0tfoy+azFL6EU1P5hMEKajLwQjivJQnLX1cA8fdz4m1qYumERaZKaGC6ccGy2vDRv4gdBC935EG0+5bKdApO/BvB4HqYs3zsMnWsrRoVwEIDTu/37K2fJHGTUpxCSG8BQkNE=
192.168.3.48:9001 Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,und;q=0.5
192.168.3.48:9001 Connection: keep-alive
192.168.3.48:9001 Referer: http://192.168.3.48:9001/image/4.jpg
192.168.3.48:9001 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44
192.168.3.48:9001 
192.168.3.48:9001 [RESPONSE] [2022-06-21T14:27:50:000] [ Duration 115µs  ↑ 96 B  ↓ 596 B ]
192.168.3.48:9001 403 Forbidden
192.168.3.48:9001 X-Amz-Request-Id: 16FA8ED7B0EBF448
192.168.3.48:9001 X-Content-Type-Options: nosniff
192.168.3.48:9001 Accept-Ranges: bytes
192.168.3.48:9001 Content-Length: 273
192.168.3.48:9001 Content-Security-Policy: block-all-mixed-content
192.168.3.48:9001 Content-Type: application/xml
192.168.3.48:9001 Vary: Origin,Accept-Encoding
192.168.3.48:9001 Server: MinIO
192.168.3.48:9001 Strict-Transport-Security: max-age=31536000; includeSubDomains
192.168.3.48:9001 X-Xss-Protection: 1; mode=block
192.168.3.48:9001 <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied.</Message><BucketName>favicon.ico</BucketName><Resource>/favicon.ico</Resource><RequestId>16FA8ED7B0EBF448</RequestId><HostId>d6ded3f6-17e0-49a3-bdd8-61e12a1ad942</HostId></Error>
192.168.3.48:9001 

second site:
192.168.3.173:9001 [REQUEST s3.HeadObject] [2022-06-21T14:31:51:000] [Client IP: 192.168.3.48]
192.168.3.173:9001 HEAD /image/4.jpg
192.168.3.173:9001 Proto: HTTP/1.1
192.168.3.173:9001 Host: 192.168.3.173:9001
192.168.3.173:9001 Authorization: AWS4-HMAC-SHA256 Credential=copy/20220621/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-minio-source-proxy-request, Signature=bc98ddaf45fcb8f02d90c6283a9aa2e59049d226a66d234200c271dfe56ce30d
192.168.3.173:9001 Content-Length: 0
192.168.3.173:9001 User-Agent: MinIO (linux; amd64) minio-go/v7.0.27
192.168.3.173:9001 X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
192.168.3.173:9001 X-Amz-Date: 20220621T062750Z
192.168.3.173:9001 X-Minio-Source-Proxy-Request: true
192.168.3.173:9001 
192.168.3.173:9001 [RESPONSE] [2022-06-21T14:31:51:000] [ Duration 2.338ms  ↑ 106 B  ↓ 489 B ]
192.168.3.173:9001 200 OK
192.168.3.173:9001 X-Amz-Replication-Status: REPLICA
192.168.3.173:9001 Content-Security-Policy: block-all-mixed-content
192.168.3.173:9001 Strict-Transport-Security: max-age=31536000; includeSubDomains
192.168.3.173:9001 Vary: Origin,Accept-Encoding
192.168.3.173:9001 X-Amz-Request-Id: 16FA8F0FCB204368
192.168.3.173:9001 ETag: "f3833a91e2597672b55e6be3178be22b"
192.168.3.173:9001 Content-Type: image/jpeg
192.168.3.173:9001 Last-Modified: Tue, 14 Jun 2022 09:08:48 GMT
192.168.3.173:9001 X-Content-Type-Options: nosniff
192.168.3.173:9001 Content-Length: 256339
192.168.3.173:9001 Server: MinIO
192.168.3.173:9001 X-Xss-Protection: 1; mode=block
192.168.3.173:9001 x-amz-version-id: c41cd8ee-95ee-4966-a57e-74143509f2b6
192.168.3.173:9001 Accept-Ranges: bytes


A 200 status code is returned the first time the client visits the page. If the page content has not changed on the second visit, the server will return a 304 status code. Strictly speaking, this is not a bug. But why the minio log has errors?
> 6.Error: API: GetObject Time: Tue Jun 21 2022 01:59:34 GMT+0800 (中国标准时间) DeploymentID: d6ded3f6-17e0-49a3-bdd8-61e12a1ad942 RequestID: 16FA803426C19DCB RemoteHost: 192.168.1.133 UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44 Error: Replication proxy failed for image/4.jpg() - At least one of the pre-conditions you specified did not hold (*fmt.wrapError) Backtrace: 0: internal/logger/logger.go:278:logger.LogIf() 1: cmd/object-handlers.go:434:cmd.objectAPIHandlers.getObjectHandler() 2: cmd/object-handlers.go:599:cmd.objectAPIHandlers.GetObjectHandler() 3: net/http/server.go:2084:http.HandlerFunc.ServeHTTP()

@poornas we shouldn't be logging this error - it looks normal case. 
Yes, Thanks

Fix patch:
diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go
index d7d930e00380c..70f09a6a8e945 100644
--- a/cmd/object-handlers.go
+++ b/cmd/object-handlers.go
@@ -420,6 +420,11 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj
 
 	gr, err := getObjectNInfo(ctx, bucket, object, rs, r.Header, readLock, opts)
 	if err != nil {
+		if isErrPreconditionFailed(err) {
+			writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
+			return
+		}
+
 		var (
 			reader *GetObjectReader
 			proxy  proxyResult


Test patch: