-
Notifications
You must be signed in to change notification settings - Fork 36
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
Uploaded file must be a non-empty zip #478
Comments
I'm also getting that same error and solved the issue by downgrading the package to version 2.5.x. It should be a high priority to fix this error. |
@pharindoko @ColinGilbert what language are you running the CDK under? |
Typescript |
I'm using Typescript |
I've been playing, and I see this error intermittently. I have a guess as to what is going on here. The empty ZIP error is coming from Lambda when this stack attempts to upload the Lambda function that does the deployment. My guess is that the functionality to download the prebuilt Lambda binary is sometimes failing, and rather than that failure being made visible, the build continues and uploads an empty ZIP. @pharindoko @ColinGilbert can one of you please try the deployment that is failing with the environment variable NO_PREBUILT_LAMBDA set to 1? This means the Lambda is built locally rather than downloaded from Github. |
Okay, I've confirmed this behavior myself. We can see that the assets for release 3.0.24 do not include the files Release 3.0.7 does include the files |
So we have two issues here:
I suggest we use this issue to address download issues not failing the build correctly. I'll open a new issue for the release issue with 3.0.24. |
As part of considering this task and #526, I think we should consider whether the prebuilt Lambda functionality is too complex and brittle, and whether it should just be ripped out entirely. Especially given the support status of this package (or lack there of). Building locally was pretty quick when I did it. |
I can also confirm that using NO_PREBUILT_LAMBDA=1 works fine |
I also had the same problem but i don't understand how the NO_PREBUILT_LAMBDA env solves the problem if the current code already build the docker image in case the download fails: My logs when the download fail:
Regardless of the image being built the lambda deployment fails with the empty message... |
I can also confirm that by downgrading and fixing the version to 3.0.23 i was able to download the prebuilt lambda without problems |
I found the problem and it can be reproduced after the second deployment, after your bootstrap file has been created. 1 - download your dependencies (node_modules) using the version 3.0.24 of cdk-ecr-deployment It seems the second deployment fails because it thinks it already has downloaded the bootstrap from github, even though actually the bootstrap file was created with cdk building the docker image for our lambda function. The problem is that the file created when deploying the docker file is actually empty, that's why the non-empty zip error happens Specifically the bug is a mixture of the library failing to download the bootstrap files and the file generated by cdk after docker build deployment being empty. You can see the bug in the install file here: bin path is set here: A simple solution would be adding an empty file check here for this specific case. Or maybe the download function is creating the file even though the download fails. In this case we should delete the file in the catch logic. @SamStephens what do you think? |
@fabiozig good piece of analysis. I was seeing intermittent failures as I tried to track this down; they baffled me, so well done finding the failure scenario. I've been wondering how this bug could have been introduced by the 3.x changes, and after reading your analysis I think it probably wasn't; that this bug has probably been present for a long time, but we're only just seeing it now because the missing prebuilt binaries in 3.0.24 mean that is the first time the failure scenario you describe has been encountered (the lambda is built locally, and then a second deployment is tried). What is confusing me is why it makes a difference that |
The file is not created when the docker image is built but when we try to download the bootstrap artifacts in the pipeline code below. That's why when using NO_PREBUILT_LAMBDA we had no problems, the download process is skipped altogether and the bootstrap file is not created. The problem is that currently whether the download is successful or not, the bootstrap file is being created. I checked the documentation on the got library and it seems like the errors on the stream should be treated separately You are right the bug was not introduced with the 3.x changes. But thinking about a general case, if the download fails because of any reason the file should not be created. Also, it seems version 3.0.24 was fixed and now the artifacts are uploaded normally, so this problem should not happen again for now. |
Well spotted, my mistake.
Agreed. Looking a little at Stackoverflow, it looks like normal practice is to I still think the best path forward is to remove the prebuilt functionality entirely, to simplify this package due to lack of support. |
It seems like this problem came back in
|
* Deps: upgrade dependencies * Fix build warning * Fix empty zip errors Context: cdklabs/cdk-ecr-deployment#478 (comment)
Can confirm seeing this error in version 3.0.67 On codepipeline synth:
Then while creating the lambda:
edit: Issue is fixed by setting 'cdk-ecr-deployment==3.0.23' as recommended above |
@mikedescalzo If you pin |
I confirmed this issue today in cdk-ecr-deployment==3.0.75 using python 3.11 but was working with 3.0.71 |
Having same issue with the latest version |
Hi @dennmee, could you please let me know which version you’re currently using? |
We pinned it to |
@mzha999 are you a maintainer of this package? If so, what do you think about removing the prebuilt Lambda functionality entirely, so the lambda is always built locally? The prebuild functionality keeps failing and causing issues, as we can see from this issue. I don't think the prebuild gains us enough to be worth maintaining, especially considering how little development work goes into this package. Docker should cache the build, so not prebuilding shouldn't actually cost developers much time. I think we're better to remove this functionality and simplify the package. We're better off having the code focus on actual function, not build optimisations we do not really need. |
Having the same issue here with 3.0.100. Changing to version 3.0.96 fixed the issue. |
Seeing same on 3.0.100 here too (aws-cdk-lib==2.140.0) Even rolling back to 3.0.99 seemed to fix the deployment for us |
faced the same issue when i set |
3.0.100 to 3.0.109 are missing the pre-built lambda. Later versions should work. We are planning on replacing the current approach with something else. |
With the latest version 3.0.7 of the construct I do get the error when I try to deploy the stack
Tested on
Macos arm64 - Sonoma 14.2.1
colima with docker 24.07
cdk 2.118.0
The text was updated successfully, but these errors were encountered: