fix(sdk): handle spaces in project directory when bundling cloud function assets - #7277
Merged
Conversation
…tion assets cdktf's TerraformAsset, when using AssetType.ARCHIVE, shells out to node .../private/fs.js <src> <dest> with a command string that does not quote the paths. When the project directory contains spaces, the shell splits on the spaces, so the archive is written to the wrong place (or fails entirely). This later surfaces as: terraform apply: opening S3 object source (assets/.../archive.zip): no such file or directory during 'wing test -t tf-aws' / 'wing compile -t tf-aws' / AWS deploys. Instead of relying on that shell string, archive the bundle directory into a zip using execFileSync with an array of arguments (no shell) so paths with spaces are preserved, then reference it as a single TerraformAsset of type FILE (which is copied with copyFileSync, no shell). This is applied to all three cloud targets (aws, azure, gcp). Fixes #6465
eladb
enabled auto-merge (squash)
August 31, 2026 14:06
|
Thanks for opening this pull request! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6465
Cloud deployment fails when the project root directory (or cwd) contains spaces (e.g.
my directory). Runningwing test -t tf-aws,wing compile -t tf-aws, or an AWS deploy fails with:Root cause
wing bundles Lambda/GCF/Azure-function code via cdktf's
TerraformAssetwithAssetType.ARCHIVE. cdktf'sarchiveSyncshells out tonode .../private/fs.js <src> <dest>using a command string that does not quote the path arguments. When a path component (the project/synth directory) contains a space, the shell splits on the space, so the archive is written to the wrong location or fails entirely. The resulting missingassets/.../archive.zipis what terraform later reports.This is the same class of bug as hashicorp/terraform-cdk#502 (still unfixed upstream), so it must be handled in wing.
Fix
Add
createArchiveinpackages/@winglang/sdk/src/shared/bundling.tsthat invokes the archiver viaexecFileSyncwith an array of arguments (no shell), so paths containing spaces are preserved. The three cloud function targets (aws, azure, gcp) now:archive.zipviacreateArchive(shell-free),TerraformAssetasAssetType.FILE, whose synthesis copies it withcopyFileSync(also no shell).The emitted
assets/<id>/<hash>/archive.zippath is unchanged, so generated terraform output is byte-identical.Verification
test/shared/bundling.test.tsconfirmscreateArchiveproduces a valid zip even when the directory path contains spaces.test/target-tf-aws/function.test.ts(11)test/target-tf-gcp/function.test.ts(6)test/target-tf-azure/function.test.ts(4)test/shared/bundling.test.ts(2)