aws-cdk: (aws-codecommit): Repository code initialization fails when empty files exist within the contents

What is the problem?

When attempting to initialize a CodeCommit repository with some code contents the stack fails with a Code 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

# Example with from_asset
dirname = os.path.dirname(__file__)
repository_code = Asset(
    scope=self,
    id="RepositoryCodeAsset",
    exclude=[".vscode", "__pycache__"],
    path=os.path.join(dirname, "code"),
)

aws_codecommit.Repository(
    scope=self,
    id="CodeCommitRepository",
    repository_name="repository_name",
    code=aws_codecommit.Code.from_asset(asset=repository_code),
)

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 the code 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 a Code 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

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 9
  • Comments: 17 (6 by maintainers)

Most upvoted comments

Any updates on this please?

Can comment inside init file so it is not empty anymore 😀