Repository: minio/minio (language: go)

Issue:
panic: "GET .............": invalid WriteHeader code 0
<!--- Provide a general summary of the issue in the Title above -->
After update to 2022-03-26T06:49:28Z we started to observe minio panic messages in syslog such as:
```
Mar 29 12:14:51 tafl-serv1 minio[2985]: panic: "GET /content/LkcB": invalid WriteHeader code 0
Mar 29 12:14:51 tafl-serv1 minio[2985]: panic: "GET /content/docs/cplugError.html/": invalid WriteHeader code 0

```
Couple of full panic logs are in attached file.
[minio_panic.txt](https://github.com/minio/minio/files/8371140/minio_panic.txt)


## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
No panic events and proper error message of the issue if any.
<!--- If you're suggesting a change/improvement, tell us how it should work -->

## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
Panic messages in minio log.
<!--- If suggesting a change/improvement, explain the difference from current behavior -->

## 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 -->

## Context
<!--- 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) -->
Yes. There were no such messages in previous version installed. Not sure which one that was. Most likely 2022-02-18T01:50:10Z.
<!-- 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 (`minio --version`): minio version RELEASE.2022-03-26T06-49-28Z
* Server setup and configuration: distributed bare-metal installation
* Operating System and version (`uname -a`): Linux tafl-serv1 5.4.0-94-generic #106-Ubuntu SMP Thu Jan 6 23:58:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux



Discussion / hints:
Looks like a regression from https://github.com/minio/minio/pull/14345/files#diff-e7bc5ddd6854880db5918a96700afb6815d4c52c9a66734d00ef9974e6c8ebc4R429

Seems we can get to object-handlers.go:456 with a nil error, which returns `var noError = APIError{}` giving a code 0. It will be a few days until I can get to this, but maybe @poornas can take a look.

Fix patch:
diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go
index 44a5b2326c1bd..ecf82fe302ac9 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
 			}
 		}


Test patch: