-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(aws-codecommit): Repository code initialization fails when empty files exist within the contents #19012
Comments
Hey @codeJack, thanks a lot for opening the issue. Confirming I was able to reproduce it. Fascinating! I'm curious whether this is limited to CodeCommit, or is this some bigger issue in how we handle Assets in the CDK. |
Interestingly, I just tried it with a Lambda function whose code includes an empty file, and everything worked without a problem! I wonder if this is some error in how the CodeCommit API handles ZIPs that include empty files...? |
This seems related: jupyterlab/jupyterlab-git#286 |
Hmm. I just tried with a manually-created ZIP file that contains just an empty file (not a CDK asset), and it was created successfully. So it does seem like this is something weird that the CDK Assets do. |
repository_code = s3_assets.Asset(
scope=self,
id="RepositoryCodeAsset",
exclude=[".vscode", "__pycache__"],
path=os.path.join(dirname, "code"),
bundling=BundlingOptions(
image=DockerImage.from_registry(
image="public.ecr.aws/docker/library/alpine:latest"
),
command=[
"sh",
"-c",
"""
apk update && apk add zip
zip -r -j /asset-output/code.zip /asset-input/*
""",
],
user="root",
),
) It seems to work fine when using |
What the hell is this ZIP sorcery that is making this fail 😄 |
Here's the CDK code creating the archive: aws-cdk/packages/cdk-assets/lib/private/archive.ts Lines 9 to 49 in 6eb775e
I don't see anything suspicious there... |
Got same error when the code contents had empty After running I tried to reference the ZIP created by CDK in below CFN template and tried deploying the stack using this template:
The stack creation failed with same Then, I tried to create the ZIP manually and added that zip to a S3 bucket. Then I created a CFN stack using below template:
The stack was created successfully. Now, this means that there is an issue in CDK during creation of ZIP file. |
Got the same error, was rather confusing to see a "Code supplied is not a valid .zip archive" when the issue was just an empty file in the directory. If at least the error message could be changed that would be helpful |
Legend mate |
Just got the same error. It took me a while to find the reason, also because the .zip archive uploaded to S3 is actually valid and correctly contains the empty file. |
Still not working as of today. |
It's been a year since the issue is opened. Still not working. |
I deleted the |
Encountered the same when trying to create a CodeCommit repository from a small directory with some source code.
Using a zip file instead worked fine.
|
Any updates on this please? |
Can comment inside init file so it is not empty anymore 😀 |
+1 this behavior seems to also be in Typescript |
What is the problem?
When attempting to initialize a CodeCommit repository with some
code
contents the stack fails with aCode supplied is not a valid .zip archive
error if, among the contents, one or more empty files exist (eg. __init__.py).This behavior applies to any of the supported Code sources :
from_asset
,from_directory
,from_zip_file
.Reproduction Steps
The
code
folder shall contain one or more empty files.What did you expect to happen?
The stack should have been deployed successfully, the code commit repository
"repository_name"
should have been created and initiated with the contents from thecode
folder.Also, the error message could have been more precise : the zip archive is perfectly valid, the issue (assuming there is one) is with its contents.
What actually happened?
cdk deploy
fails with aCode supplied is not a valid .zip archive
error on the CodeCommit resource.CDK CLI Version
2.8.0 (build 8a5eb49)
Framework Version
aws-cdk-lib==2.8.0
Node.js Version
v16.10.0
OS
MacOS 11.6.3
Language
Python
Language Version
Python(3.9.10)
Other information
No response
The text was updated successfully, but these errors were encountered: