Skip to content

Commit 0d7ae40

Browse files
committed
Fix: add error msg when bad s3 creds
1 parent 00d85f8 commit 0d7ae40

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

aodn_cloud_optimised/lib/s3Tools.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff 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"]

0 commit comments

Comments
 (0)