Skip to content

Commit

Permalink
CLDSRV-462 Expiration header is not compatible with legacy object md
Browse files Browse the repository at this point in the history
Before the Object Metadata refactor done around May 31, 2017 (c22e44f), if no tags were set, the object tag was stored as undefined.

After the commit, if no tags are set, the object tag is stored as an empty object '{}'.

When the expiration response headers were implemented on 812b09a around Nov 22, 2021, the empty object was handled, but not the undefined tag logic, which made the expiration response headers not backward compatible.

We need to address both cases: the undefined property and the empty object '{}'.
  • Loading branch information
nicolas2bert committed Oct 25, 2023
1 parent 67e5694 commit 4d91687
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/api/apiUtils/object/expirationHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,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 };
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s3",
"version": "7.10.31",
"version": "7.10.32",
"description": "S3 connector",
"main": "index.js",
"engines": {
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/api/apiUtils/expirationHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
{
Expand Down

0 comments on commit 4d91687

Please sign in to comment.