Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip cleanup of files that don't match the regex #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Matthew-Smith
Copy link

We had an issue where we had added a couple files to our bucket which was used by serverless

The error we saw:

Type Error ---------------------------------------------
 
  Cannot read property '4' of null
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     OS:                     linux
     Node Version:           10.16.0
     Serverless Version:     1.44.1
 
ERROR: Job failed: command terminated with exit code 1

basically, file.name.match(/(serverless)\/(.+)\/(.+)\/(\d+)-(.+)\/(.+\.zip)/)[4] was failing because foo.js did not match the regex (returns null)

@eLRuLL
Copy link

eLRuLL commented May 20, 2020

any plans for merging this fix?

I had to add the main.py file directly into the root of the artifact zip. Getting the same error.

return timestamp;
}, ['asc']);

// 4 old ones + the one which will be uploaded after the cleanup = 5
const objectsToKeepCount = 4;

const objectsToKeep = _.takeRight(orderedObjects, objectsToKeepCount);
const objectsToRemove = _.pullAllWith(files, objectsToKeep, _.isEqual);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const objectsToRemove = _.pullAllWith(files, objectsToKeep, _.isEqual);
const objectsToRemove = _.pullAllWith(filteredFiles, objectsToKeep, _.isEqual);

You can't just use all files list because there are directory paths that has other files that we want to keep in objectsToKeep, then I suggest this change on the code

@pethersonmoreno
Copy link

I found the same error and with the suggestion the problem was fixed to me testing on local.
These changes solves the problem in Issue: #228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants