Skip to content

Commit afb57ce

Browse files
authored
Merge pull request #142 from jrjohnson/v3-fix
Handle empty s3 response
2 parents 9c7fc45 + 21343ca commit afb57ce

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
root: true,
33
parserOptions: {
4-
ecmaVersion: 6,
4+
ecmaVersion: 'latest',
55
sourceType: 'module'
66
},
77
extends: 'eslint:recommended',

lib/s3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ module.exports = CoreObject.extend({
166166
var revisionPrefix = joinUriSegments(prefix, options.filePattern + ":" + options.revisionKey);
167167

168168
return listObjects({ Bucket: bucket, Prefix: revisionPrefix })
169-
.then((response) => response.Contents.find((element) => element.Key === revisionPrefix));
169+
.then((response) => response.Contents?.find((element) => element.Key === revisionPrefix));
170170
},
171171

172172
fetchRevisions: function(options) {

tests/unit/lib/s3-test.js

+9
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ describe('s3', function() {
242242
});
243243
});
244244

245+
it('succeeds when revision key search returns no values', function() {
246+
s3Client.listObjects = function(params, cb) {
247+
cb(undefined, {});
248+
};
249+
var promise = subject.upload(options);
250+
251+
return assert.isFulfilled(promise);
252+
});
253+
245254
describe("when revisionKey was already uploaded", function() {
246255
beforeEach(function() {
247256
options.revisionKey = "123";

0 commit comments

Comments
 (0)