-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
lambda: corrupt zip archive asset produced when using node v15.6 #12536
Comments
@machielg -- could you update the title, maybe to "Uploaded Zips of Functions are Empty". I'm running into the same issue and want to ensure it's visible. |
Running into the same issue now with //EDIT: I can see the asset was bundled locally (e.g., OS: Catalina |
I had the same issue today with a customer using the serverless framework. So it might be something outside CDK, also. |
I think you're right... Although I just tried it with us-east-1 and us-west-1 to no avail; so I don't think it's with AWS infra either. Curious where the issue is, then. |
Very similar issue, zip downloaded shows CRC errors but files are present and 7zip can recover them. Error is "Uploaded file must be a non-empty zip" |
I didn't have issues with deploying the |
What versions of Node do y'all use? As a wild guess, I think it might be a node 15 issue. |
v15.6.0 |
I updated to node 15.6.0 just yesterday when also this bug started so it’s a likely suspect. Downgrading to node 14 didn’t seem to help though. I’m planning to run it in a docker container to isolate the library responsible. |
I’m having the same issue on Node 12 |
I tested with several node versions, I can't get it to work with any version (10, 14, 15). It's clear that zipping of my asset dir with the python code isn't triggered, the zip file with the code isn't created. I just updated all packages and it seems to work again. |
Which packages did you update and using what commands? |
I got an update for @types/node to version 14.14.21 which was released very recently. |
I had the same issue after upgrading to 15.6.0. Downgrading (and deleting cdk.out/.cache and deleting the zip files on the s3 bucket) worked! |
Perhaps you can list your relevant package versions? |
@machielg Which package version? |
@machielg They have nothing to do with it... as I wrote downgrading node itself and deleting the caches is enough. |
@danilobuerger I removed the cache and s3 assets but that didn’t work for me so I’m trying to find out what fixed it |
@machielg you probably did not clear the caches. |
@machielg please read above, I mentioned it in my first comment here.... |
Thx @danilobuerger ! Downgrading to Node@14, deleting the cdk dir and Remove Zip from S3 worked for me |
@therealsebo Awesome! It seems to me that everything including 15.5.1 is working. |
I am also facing this issue. |
it was working for me yesterday, but this morning it failed again. The zip file created by CDK contains all the files, but they are all empty. The issue seems to be coming from the archiver lib: |
Downgrading to Node v15.5.1 and doing a proper clean seems to fix the problem. |
Thanks @machielg. I downgraded to Node v14.15.4 and to node-archiver 5.1.0. So far it is looking OK now. |
Ran into this issue today with node v12.20.0 and CDK version 1.84.0. Downgraded to CDK version 1.74.0 to get it working again. |
I met the error Looks like the fix still has problem in case updating the existing stack. The stack updating succeeded after using above script to clean all assets in |
Same issue on Mac 11.2.3 with Node 15.14.0 and cdk 1.97.0 Sometimes I have another error : |
My currently working configuration is Node v14.16.1 (LTS) and CDK version 1.100.0. As others have stated, clearing the staging bucket of affected assets is required to fix this problem. After becoming aware of this issue, running My issue was resolved after updating to the previously mentioned Node and CDK versions, then removing the assets which were indicated in the verbose output produced by the |
Reduce version of node ref aws/aws-cdk/issues/12536.
Encountered the present issue in the past and dev team's response did work, but now I faced the problem again following update of aws-cdk from 1.113.0 to 1.114.0 with node 14.17.3. After downgrading aws-cdk back to 1.113.0 and cleaning the staging bucket, everything worked fine again. Hope you guys will find a real fix soon. 🙏 |
This ugly script fixes assets after deploy so you can deploy again. Run it in the root folder of your project so it can find
|
I'm seeing this in 1.121.0 today. |
@timmattison does anyone else perform deployments who might be using an older version? Are you able to replicate after clearing out the affected assets from the bucket? Is it possible for you to share the log output using the |
@timmattison can you share you package.json and package-lock.json files? |
Of course I fixed this before I went on vacation and now I don't remember what I changed. It was an error on my end but the error message didn't help me diagnose what was wrong. I'll take a look and see what I can find and report back either way. |
I can't find it now. I want to say that this was an issue where there was a require that was referencing a file that didn't exist but in CDK 122 it seems to throw an error early saying that the module couldn't be found. If I ever figure it out I'll post it here but for now I think we will have to ignore it without reproduction steps. :-/ |
just tried with node 16.13.0 and cdk 132 and everything seems fine! thx yall! |
Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date. Closes aws/aws-cdk#12536
For future reference, I'm adding my experience with this issue. Configuration
I had a Gradle project for each Lambda handler and a Gradle project for CDK code, i.e.,
Each Lambda handler project used the Java application Gradle plugin, so when bundling locally, I had to use
since So what I would try to run is The key observation that ultimately helped me was the following. Upon running To fix the issue, I simply deleted This is only the second project I have worked with CDK, so I may be missing some critical detail about how to properly use CDK or the CDK CLI that would've avoided this issue, but it didn't seem to be caused by any partcular version of software I was using. |
Update from the CDK team
When using local assets with the lambda module using the
Code.fromAsset()
API, deployment of new assets (duringcdk deploy
) will fail with the error - "Uploaded file must be a non-empty zip"We have confirmed this issue manifests when using node engine v15.6. The root cause is being tracked by node - nodejs/node#37027. For the time being, use a node engine <
15.6
.If you have encountered this issue, you need to do three things to resolve this -
15.6
. You can see what you're current node version is by runningnode --version
.cdk.out/
directory. You could safely delete the entire directory, and the correct assets and templates will be re-generated during the next run ofcdk synth
orcdk deploy
.asset/
and have the hash of the asset. The hash of the asset can be found in your application's CloudFormation template.The staging bucket can be obtained by running the following command -
aws cloudformation describe-stack-resources --stack-name CDKToolkit --logical-resource-id StagingBucket --query 'StackResources[].PhysicalResourceId'
Original issue filed below
When doing
my file is here (relative to root of the CDK project):
lib/python/mylambda.py
its contents:
I get the error:
Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: fcfaf553-70d3-40b8-85d2-a15f6c3bcef0; Proxy: null)
Reproduction Steps
run
cdk deploy
What did you expect to happen?
the Lambda is created in AWS
What actually happened?
An zip file is uploaded to the CDK staging bucket, there is a zip file there with my python file, but that file has no contents
Environment
Other
I'm suspecting it's a nodejs/library problem, in that some library is producing this invalid zip file but I have no evidence of this.
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: