serverless: Mac: aws-go-mod deploy failed Uploaded file must be a non-empty zip

On my local Mac, I was trying the aws-go-mod template and sls deploy failed with

  An error occurred: HelloLambdaFunction - Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: a9d772b9-c1d9-4e74-a6ab-6be5af6feb5e; Proxy: null).
serverless.yml

I did not make any change to serverless.yml out of the template.

⚠️⚠️ REPLACE WITH FULL COMMAND NAME output
> serverless config credentials --provider provider --key key --secret secret

> sls create --template aws-go-mod --path myservice
> cd myservice
> make build
> make deploy
  Serverless Error ---------------------------------------

  An error occurred: HelloLambdaFunction - Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 5125656a-c0d3-446d-badd-bca2f7063331; Proxy: null).

Installed version

╰─➤  sls --version
Framework Core: 2.19.0
Plugin: 4.4.2
SDK: 2.3.2
Components: 3.4.7

I also tried with sls package first then sls deploy --package, also same issue.

╰─➤  sls package --package ~/Downloads/test
Serverless: Packaging service...
Serverless: Excluding development dependencies...
╰─➤  ls -ltrh ~/Downloads/test                                                                                                                                       1 ↵
total 12512
-rw-r--r--  1 ifanchu  staff   2.0K Jan 15 23:57 cloudformation-template-create-stack.json
-rw-r--r--  1 ifanchu  staff    11K Jan 15 23:57 cloudformation-template-update-stack.json
-rw-r--r--  1 ifanchu  staff   6.1M Jan 15 23:57 myservice.zip
-rw-r--r--  1 ifanchu  staff    19K Jan 15 23:57 serverless-state.json
╰─➤  sls deploy --package ~/Downloads/test

Serverless Error ---------------------------------------

  An error occurred: WorldLambdaFunction - Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 2f191f1a-2582-4d7d-8c85-1705f2384778; Proxy: null).

Am I doing anything wrong with the template?

AWS Setting

╰─➤  cat ~/.aws/config
[default]
region = us-west-2

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 19
  • Comments: 30 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks everyone for checking out and confirming that it’s in fact related to node v15.6.0. I’ve managed to pinpoint the issue to the library that we’re using to create zip archives - https://github.com/archiverjs/node-archiver/issues/491. I’ll be tracking the issue and make sure to let everyone here know as soon as we have a resolution. 💯

I was on v15.6.0

╰─➤  node --version
v15.6.0

I downgraded to

╰─➤  node -v
v14.15.4
╰─➤  npm -v
6.14.10

And it is working good now.

Hello everyone - thanks a lot for reporting more details about the issue. I’ve had a hard time reproducing it, but seeing output from @lxwang42 I’ve noticed use of the latest version of node v15.6.0 and in fact, I was able to reproduce the issue on both framework versions v2.18.0 and v2.19.0. Surprisingly, when going back to node v14 or even to v15.5.0, the problem does not exist (or at least I wasn’t able to reproduce). It seems like the packaged zips are broken as when even trying to unzip them locally they error out with bad CRC as was also shown by @ifanchu.

The question to everyone reporting - are you all on node v15.6.0 or is there anyone that experiences the same issue with different node versions? I tried v10, v12, v14, v15.5.0 and could not reproduce. For now, I’ll continue the investigation under the assumption that issue is present only on the v15.6.0 of node.

Thanks everyone for detailed reports 🙇

node v16 - same issue… fixed by overriding crc32-stream version by:

"resolutions": {
    "crc32-stream": "4.0.2"
}

in package.json

I can also confirm I was running Node v15.6.0 and when I rolled back to Node v14.15.1 all is working fine so it seems to be Node related

To let everyone know, it has been confirmed to be a Node issue: https://github.com/nodejs/node/issues/37027

I can also confirm I was running Node v15.6.0 and when I rolled back to Node v14.15.1 all is working fine so it seems to be Node related

I’ve had to roll back as well from v15.6.0 and v14.15.1 worked.

I’ve tested with Node 15.5 and it is working. It seams to be broken only on 15.6.

Hello everyone 👋 The original issue has been resolved and new version of crc32-stream has been published. All new serverless installations should use that version by default. I’m closing this issue, but if you’re still running into errors please let us know 🙇

Confirmed working with node@14

I created a small reproducer repository. See the Github action and the latest output.

i’m having the same issue, tested on fresh osx and debian 10 with nodejs helloworld example. got the same error

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              15.6.0
     Framework Version:         2.19.0
     Plugin Version:            4.4.2
     SDK Version:               2.3.2
     Components Version:        3.4.7
service: helloworld
frameworkVersion: '2'

provider:
  name: aws
  runtime: nodejs12.x
  lambdaHashingVersion: 20201221

functions:
  hello:
    handler: handler.hello

I’m having the exact same issue today with code that was working perfectly before. I’m working with serverless 2.19.0 but I’ve also downgraded to 2.18.0

I’m testing with a Python lambda function, even a simple hello world function won’t deploy with the following error

Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException;

Confirmed rolling back from node @ 15.6.0 to 14.15.4 fixed the problem for me.