fix: CDK app fails to launch if paths contain spaces#1045
Merged
aws-cdk-automation merged 3 commits intomainfrom Jan 21, 2026
Merged
fix: CDK app fails to launch if paths contain spaces#1045aws-cdk-automation merged 3 commits intomainfrom
aws-cdk-automation merged 3 commits intomainfrom
Conversation
When executing CDK apps, users specify the command as a string. The only feasible interpretation of that is by executing the command line through a shell, either `bash` or `cmd.exe`. We are using shell execution on purpose: - It's used for tests - It's necessary on Windows to properly execute `.bat` and `.cmd` files - Since we have historically offered it you can bet dollars to doughnuts that customers have built workflows depending on that. This is all a preface to explain why we don't have an `argv` array. Automated code scanning tools will probably complain, but we can't change any of this. And since the source of the string and the machine it's executing on are part of the same security domain (it's all "the customer": the customer writes the command string, then executes it on their own machine), that is fine. However, historically we did do trivial parsing and preprocessing of that `string` in order to help the user achieve success. Specifically: if the string pointed to a `.js` file we would run that `.js` file through a Node interpreter, even if: - The file was not marked as executable on POSIX; or - There was no shell association set up for `.js` files on Windows. That light parsing used to fail in the following cases: - If the pointed-to file had spaces in its path. - If Node was installed in a location that had spaces in its path. In this PR we document the choice of command line string a bit better, and handle the cases where the file or interpreter paths can have spaces in them. We still don't do fully generic command line parsing, because it's extremely complex on Windows and we can probably not do it correctly; we're just concerned with quoting the target and interpreter. Closes #636
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1045 +/- ##
==========================================
- Coverage 87.72% 87.69% -0.04%
==========================================
Files 72 72
Lines 10088 10095 +7
Branches 1330 1332 +2
==========================================
+ Hits 8850 8853 +3
- Misses 1213 1217 +4
Partials 25 25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mrgrain
approved these changes
Jan 21, 2026
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.
When executing CDK apps, users specify the command as a string. The only feasible interpretation of that is by executing the command line through a shell, either
bashorcmd.exe.We are using shell execution on purpose:
.batand.cmdfilesThis is all a preface to explain why we don't have an
argvarray. Automated code scanning tools will probably complain, but we can't change any of this. And since the source of the string and the machine it's executing on are part of the same security domain (it's all "the customer": the customer writes the command string, then executes it on their own machine), that is fine.On that string the user gave us, historically we did do a bit of trivial parsing and preprocessing of that
stringin order to help the user achieve success. Specifically: if the string pointed to a.jsfile we would run that.jsfile through a Node interpreter, even if there would be potential misconfiguration obstacles in the way:tscinvocation); or.jsfiles on Windows.In both cases we would prepend our own Node executable's path to the command line in order to successfully run the "naked"
.jsfile.That behavior used to fail in the following cases:
In this PR we document the choice of command line string a bit better, and handle the cases where the file or interpreter paths can have spaces in them.
We still don't do fully generic command line parsing, because it's extremely complex on Windows and we can probably not do it correctly; we're just concerned with quoting the target and interpreter.
Historically it has been possible (though not widely documented) for the
{ "app" }entry to contain astring[](argv array). We traditionally used to join this back to a single space-separated string, even without applying quotes, so you wouldn't really benefit from that. Nevertheless, this PR retains that behavior.Closes #636
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license