File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,8 +167,18 @@ def delete_objects_in_prefix(
167167 },
168168 )
169169
170- logger .info (f"Deleted { len (delete_response ['Deleted' ])} objects." )
170+ # Raise if the API call did not return the 'Deleted' list
171+ if "Deleted" not in delete_response :
172+ if delete_response .get ("Errors" ):
173+ code = delete_response .get ("Errors" )[0 ]["Code" ]
174+ msg = delete_response .get ("Errors" )[0 ]["Message" ]
175+ raise RuntimeError (f"{ code } : { msg } " )
176+ else :
177+ raise RuntimeError (
178+ "S3 delete_objects response did not include 'Deleted'. Possible failure."
179+ )
171180
181+ logger .info (f"Deleted { len (delete_response ['Deleted' ])} objects." )
172182 # Check if there are more objects to delete
173183 if response ["IsTruncated" ]:
174184 continuation_token = response ["NextContinuationToken" ]
You can’t perform that action at this time.
0 commit comments