diff --git a/lib/api/apiUtils/object/expirationHeaders.js b/lib/api/apiUtils/object/expirationHeaders.js index 94d3037f2e..a815619777 100644 --- a/lib/api/apiUtils/object/expirationHeaders.js +++ b/lib/api/apiUtils/object/expirationHeaders.js @@ -39,8 +39,10 @@ const AMZ_ABORT_ID_HEADER = 'x-amz-abort-rule-id'; function _generateExpHeadersObjects(rules, params, datetime) { const tags = { - TagSet: Object.keys(params.tags) - .map(key => ({ Key: key, Value: params.tags[key] })), + TagSet: params.tags + ? Object.keys(params.tags) + .map(key => ({ Key: key, Value: params.tags[key] })) + : [], }; const objectInfo = { Key: params.key }; diff --git a/tests/unit/api/apiUtils/expirationHeaders.js b/tests/unit/api/apiUtils/expirationHeaders.js index d1bc0ddaf5..41fa1af48c 100644 --- a/tests/unit/api/apiUtils/expirationHeaders.js +++ b/tests/unit/api/apiUtils/expirationHeaders.js @@ -103,6 +103,16 @@ describe('generateExpirationHeaders', () => { }, {}, ], + [ + 'should provide correct headers for compatibility with legacy objects missing the tags property', + { + lifecycleConfig: lifecycleExpirationDays, + objectParams: { key: 'object', date: objectDate }, + }, + { + 'x-amz-expiration': `expiry-date="${expectedDaysExpiryDate}", rule-id="test-days"`, + }, + ], [ 'should return correct headers for object (days)', {