Skip to content

Commit

Permalink
Check s3 DeleteObjects response for errors (#18885)
Browse files Browse the repository at this point in the history
  • Loading branch information
WVerlaek authored Oct 6, 2023
1 parent cbc3083 commit a16ca4f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/content-service/pkg/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (rs *PresignedS3Storage) DeleteObject(ctx context.Context, bucket string, q
return nil
}

_, err := rs.client.DeleteObjects(ctx, &s3.DeleteObjectsInput{
resp, err := rs.client.DeleteObjects(ctx, &s3.DeleteObjectsInput{
Bucket: &rs.Config.Bucket,
Delete: &types.Delete{
Objects: objects,
Expand All @@ -137,6 +137,13 @@ func (rs *PresignedS3Storage) DeleteObject(ctx context.Context, bucket string, q
if err != nil {
return err
}
if len(resp.Errors) > 0 {
var errs []string
for _, e := range resp.Errors {
errs = append(errs, fmt.Sprintf("%s: %s", aws.ToString(e.Key), aws.ToString(e.Message)))
}
return xerrors.Errorf("cannot delete objects: %s", strings.Join(errs, ", "))
}

return nil
}
Expand Down

0 comments on commit a16ca4f

Please sign in to comment.