Skip to content

Commit

Permalink
Use safe stringify for AWS delete errors
Browse files Browse the repository at this point in the history
The error doesn't necessary have all fields and we can end up
dereferencing a nil pointer causing a panic.
  • Loading branch information
hifi committed Jan 5, 2024
1 parent 444ad71 commit ff96dae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions s3/replica_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit ff96dae

Please sign in to comment.