Skip to content

fix(sdk): handle spaces in project directory when bundling cloud function assets - #7277

Merged
eladb merged 1 commit into
mainfrom
claude/fix-6465-spaces-in-path
Aug 31, 2026
Merged

fix(sdk): handle spaces in project directory when bundling cloud function assets#7277
eladb merged 1 commit into
mainfrom
claude/fix-6465-spaces-in-path

Conversation

@eladb

@eladb eladb commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #6465

Cloud deployment fails when the project root directory (or cwd) contains spaces (e.g. my directory). Running wing test -t tf-aws, wing compile -t tf-aws, or an AWS deploy fails with:

terraform apply: opening S3 object source (assets/.../archive.zip): no such file or directory

Root cause

wing bundles Lambda/GCF/Azure-function code via cdktf's TerraformAsset with AssetType.ARCHIVE. cdktf's archiveSync shells out to node .../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 missing assets/.../archive.zip is 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 createArchive in packages/@winglang/sdk/src/shared/bundling.ts that invokes the archiver via execFileSync with an array of arguments (no shell), so paths containing spaces are preserved. The three cloud function targets (aws, azure, gcp) now:

  1. bundle their code directory as before,
  2. archive it into a archive.zip via createArchive (shell-free),
  3. pass that single zip to TerraformAsset as AssetType.FILE, whose synthesis copies it with copyFileSync (also no shell).

The emitted assets/<id>/<hash>/archive.zip path is unchanged, so generated terraform output is byte-identical.

Verification

  • New unit test in test/shared/bundling.test.ts confirms createArchive produces a valid zip even when the directory path contains spaces.
  • Existing SDK target tests pass with unchanged snapshots:
    • 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)

…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
eladb requested a review from a team as a code owner August 31, 2026 14:06
@eladb
eladb enabled auto-merge (squash) August 31, 2026 14:06
@github-actions

Copy link
Copy Markdown

Thanks for opening this pull request! 🎉
Please consult the contributing guidelines for details on how to contribute to this project.
If you need any assistance, don't hesitate to ping use over Discord.

@eladb
eladb merged commit d1baddf into main Aug 31, 2026
9 of 11 checks passed
@eladb
eladb deleted the claude/fix-6465-spaces-in-path branch August 31, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloud deployment fails if root directory contains spaces

1 participant