Fix: guard against None contents in S3 download and upload listing#13
Conversation
|
Hi @pigeio, |
Hi @sanvishukla, |
|
Thanks @pigeio for being open to the suggestion, and I appreciate the co-author credit! Looking forward to the updated commit! |
|
Retargeted to |
201d3e7 to
e506011
Compare
|
@SeaCelo This PR is ready for review — reviewer feedback has been addressed |
46c9b0e to
75a13c0
Compare
|
This still looks like a valid small follow-up on the current mainline, since the S3 |
|
@SeaCelo Makes perfect sense! Glad to see the macOS integration successfully merged into main. The PR is clean and ready to go whenever you are doing the next batch of merges. Thanks for the update! |
|
Merging. Note: S3 sync is currently disabled ( |
Summary
What changed: Added
if contents:guard before iterating over S3list_objects_v2response inSyncS3.downloadSync()and the duplicated pagination logic in UploadRoute.py. This prevents aTypeErrorcrash when the S3 prefix matches no objects.Why: AWS
list_objects_v2omits theContentskey entirely (rather than returning an empty list) when no objects match. The code iterated directly overNone, causingTypeError: 'NoneType' is not iterable.Related issues
Validation
Tested with mock AWS responses simulating both normal and empty S3 results:
=== Testing with NORMAL response ===
Keys: ['case1/data.json']
Dirs: ['case1/subfolder/']
PASSED
=== Testing with EMPTY response (the bug scenario) ===
Keys: []
Dirs: []
PASSED
=== Proving the BUGGY version crashes ===
Confirmed bug: 'NoneType' object is not iterable
Documentation
No documentation changes needed — this is a bug fix with no API or workflow changes.
Scope check
OSeMOSYS/MUIOdependencyEAPD-DRB/MUIOGO:main(not upstream)