Contents key in list_objects S3 API response might be missing
Quite some code in CKI assumes that the Contents key in the list_objects response is always present. This is actually not the case for empty lists.
For awscli, empty listings returned an empty response up until botocore 1.29.154. As this was most often used with '.Contents[]', this just resulted in an empty jq pipeline. Since 1.29.155, the RequestCharged key is included, which now results in a return value for an empty listing of a dict with the Contents key missing, which explodes jq:
$ aws s3api list-objects --bucket BUCKET --prefix something | jq '.Contents[]'
jq: error (at <stdin>:3): Cannot iterate over null (null)
This needs to be fixed all over CKI. For jq, it might be enough to change .Contents[]
to .Contents[]?
.
AC:
-
pipeline-definition: !1806 (merged) -
cki-tools: cki-tools!998 (merged)
Edited by Michael Hofmann