From a8f0ba54bd4869844f54e8b7728c5cd7910aa202 Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Fri, 5 Jan 2024 06:03:58 +0200 Subject: [PATCH] Stringify S3 delete errors The error doesn't necessary have all fields and we can end up dereferencing a nil pointer causing a panic. --- s3/replica_client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s3/replica_client.go b/s3/replica_client.go index 3d2ddffd..d5636115 100644 --- a/s3/replica_client.go +++ b/s3/replica_client.go @@ -763,9 +763,9 @@ func deleteOutputError(out *s3.DeleteObjectsOutput) error { case 0: return nil case 1: - return fmt.Errorf("deleting object %s: %s - %s", *out.Errors[0].Key, *out.Errors[0].Code, *out.Errors[0].Message) + return fmt.Errorf("deleting object: %s", out.Errors[0].String()) default: - return fmt.Errorf("%d errors occurred deleting objects, %s: %s - (%s (and %d others)", - len(out.Errors), *out.Errors[0].Key, *out.Errors[0].Code, *out.Errors[0].Message, len(out.Errors)-1) + return fmt.Errorf("%d errors occurred deleting objects: %s (and %d others)", + len(out.Errors), out.Errors[0].String(), len(out.Errors)-1) } }