From 5b8599e52d7a5f3a985464e3a4bdcc5455ec2ccd Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 10 Oct 2023 08:35:03 -0700 Subject: [PATCH] Do not log invalid tag errors (#18200) Eliminate logging on invalid tags: ``` API: PutObjectTagging(bucket=aws-sdk-go-test-aupmzek4341ee2, object=sgehiqp24fwt4hafffmtwzkrqnq325) Time: 07:40:33 UTC 10/10/2023 DeploymentID: f122cbfa-42b1-428f-9002-39c644cace71 RequestID: 178CAF0DE0A67480 RemoteHost: 127.0.0.1 Host: 127.0.0.1:9001 UserAgent: aws-sdk-go/1.44.257 (go1.21.0; linux; amd64) Error: Tags cannot be more than 10 (*tags.errTag) 5: internal\logger\logger.go:259:logger.LogIf() 4: cmd\api-errors.go:2350:cmd.toAPIErrorCode() 3: cmd\api-errors.go:2375:cmd.toAPIError() 2: cmd\object-handlers.go:2912:cmd.objectAPIHandlers.PutObjectTaggingHandler() 1: net\http\server.go:2136:http.HandlerFunc.ServeHTTP() API: PutObjectTagging(bucket=aws-sdk-go-test-aupmzek4341ee2, object=sgehiqp24fwt4hafffmtwzkrqnq325) Time: 07:40:33 UTC 10/10/2023 DeploymentID: f122cbfa-42b1-428f-9002-39c644cace71 RequestID: 178CAF0DE0BEA514 RemoteHost: 127.0.0.1 Host: 127.0.0.1:9001 UserAgent: aws-sdk-go/1.44.257 (go1.21.0; linux; amd64) Error: Cannot provide multiple Tags with the same key (*tags.errTag) 5: internal\logger\logger.go:259:logger.LogIf() 4: cmd\api-errors.go:2350:cmd.toAPIErrorCode() 3: cmd\api-errors.go:2375:cmd.toAPIError() 2: cmd\object-handlers.go:2912:cmd.objectAPIHandlers.PutObjectTaggingHandler() 1: net\http\server.go:2136:http.HandlerFunc.ServeHTTP() API: PutObjectTagging(bucket=aws-sdk-go-test-aupmzek4341ee2, object=sgehiqp24fwt4hafffmtwzkrqnq325) Time: 07:40:33 UTC 10/10/2023 DeploymentID: f122cbfa-42b1-428f-9002-39c644cace71 RequestID: 178CAF0DE0E78970 RemoteHost: 127.0.0.1 Host: 127.0.0.1:9001 UserAgent: aws-sdk-go/1.44.257 (go1.21.0; linux; amd64) Error: The TagKey you have provided is invalid (*tags.errTag) 5: internal\logger\logger.go:259:logger.LogIf() 4: cmd\api-errors.go:2350:cmd.toAPIErrorCode() 3: cmd\api-errors.go:2375:cmd.toAPIError() 2: cmd\object-handlers.go:2912:cmd.objectAPIHandlers.PutObjectTaggingHandler() 1: net\http\server.go:2136:http.HandlerFunc.ServeHTTP() API: PutObjectTagging(bucket=aws-sdk-go-test-aupmzek4341ee2, object=sgehiqp24fwt4hafffmtwzkrqnq325) Time: 07:40:33 UTC 10/10/2023 DeploymentID: f122cbfa-42b1-428f-9002-39c644cace71 RequestID: 178CAF0DE1002AE8 RemoteHost: 127.0.0.1 Host: 127.0.0.1:9001 UserAgent: aws-sdk-go/1.44.257 (go1.21.0; linux; amd64) Error: The TagValue you have provided is invalid (*tags.errTag) 5: internal\logger\logger.go:259:logger.LogIf() 4: cmd\api-errors.go:2350:cmd.toAPIErrorCode() 3: cmd\api-errors.go:2375:cmd.toAPIError() 2: cmd\object-handlers.go:2912:cmd.objectAPIHandlers.PutObjectTaggingHandler() 1: net\http\server.go:2136:http.HandlerFunc.ServeHTTP() ``` --- cmd/api-errors.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/api-errors.go b/cmd/api-errors.go index 98117f405..7fadcb6b7 100644 --- a/cmd/api-errors.go +++ b/cmd/api-errors.go @@ -2337,6 +2337,12 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) { case dns.ErrBucketConflict: apiErr = ErrBucketAlreadyExists default: + if _, ok := err.(tags.Error); ok { + // tag errors are not exported, so we check their custom interface to avoid logging. + // The correct type is inserted by toAPIError. + apiErr = ErrInternalError + break + } var ie, iw int // This work-around is to handle the issue golang/go#30648 //nolint:gocritic