Skip to content

Commit

Permalink
Merge pull request #142 from jrjohnson/v3-fix
Browse files Browse the repository at this point in the history
Handle empty s3 response
  • Loading branch information
lukemelia authored Apr 5, 2024
2 parents 9c7fc45 + 21343ca commit afb57ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
ecmaVersion: 'latest',
sourceType: 'module'
},
extends: 'eslint:recommended',
Expand Down
2 changes: 1 addition & 1 deletion lib/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ module.exports = CoreObject.extend({
var revisionPrefix = joinUriSegments(prefix, options.filePattern + ":" + options.revisionKey);

return listObjects({ Bucket: bucket, Prefix: revisionPrefix })
.then((response) => response.Contents.find((element) => element.Key === revisionPrefix));
.then((response) => response.Contents?.find((element) => element.Key === revisionPrefix));
},

fetchRevisions: function(options) {
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/lib/s3-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ describe('s3', function() {
});
});

it('succeeds when revision key search returns no values', function() {
s3Client.listObjects = function(params, cb) {
cb(undefined, {});
};
var promise = subject.upload(options);

return assert.isFulfilled(promise);
});

describe("when revisionKey was already uploaded", function() {
beforeEach(function() {
options.revisionKey = "123";
Expand Down

0 comments on commit afb57ce

Please sign in to comment.