From 53d6f59ff576552a83760bdc76049169ee191eac Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Fri, 17 Jan 2025 20:11:22 +0530 Subject: [PATCH] shared/filestore: Add detailed error context for S3.TestConnection (#29838) We were just returning a string without embedding the actual error returned. This was making things difficult to debug. ```release-note NONE ``` Co-authored-by: Mattermost Build --- server/platform/shared/filestore/s3store.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/platform/shared/filestore/s3store.go b/server/platform/shared/filestore/s3store.go index d2f71823c7..ba496dd5f4 100644 --- a/server/platform/shared/filestore/s3store.go +++ b/server/platform/shared/filestore/s3store.go @@ -7,6 +7,7 @@ import ( "bytes" "context" "crypto/tls" + "fmt" "io" "io/fs" "net/http" @@ -215,7 +216,7 @@ func (b *S3FileBackend) TestConnection() error { if obj.Err != nil { typedErr := s3.ToErrorResponse(obj.Err) if typedErr.Code != bucketNotFound && typedErr.Code != invalidBucket { - return &S3FileBackendAuthError{DetailedError: "unable to list objects in the S3 bucket"} + return &S3FileBackendAuthError{DetailedError: fmt.Sprintf("unable to list objects in the S3 bucket: %v", typedErr)} } exists = false } @@ -224,7 +225,7 @@ func (b *S3FileBackend) TestConnection() error { if err != nil { typedErr := s3.ToErrorResponse(err) if typedErr.Code != bucketNotFound && typedErr.Code != invalidBucket { - return &S3FileBackendAuthError{DetailedError: "unable to check if the S3 bucket exists"} + return &S3FileBackendAuthError{DetailedError: fmt.Sprintf("unable to check if the S3 bucket exists: %v", typedErr)} } } }