Skip to content

fix(cli-test): invoke commands without shell intermediate#2582

Merged
zimeg merged 12 commits intomainfrom
zimeg-cli-test-fix-windows
May 7, 2026
Merged

fix(cli-test): invoke commands without shell intermediate#2582
zimeg merged 12 commits intomainfrom
zimeg-cli-test-fix-windows

Conversation

@zimeg
Copy link
Copy Markdown
Member

@zimeg zimeg commented May 6, 2026

Summary

This PR changes how the slack process is spawned. Commands were routed through a shell either /bin/sh or as cmd.exe /s /c before invoking the provided command. Now slack commands are invoked direct.

This fixes:

  • Windows Docker hangs: Child processes spawned before these changes inherited Docker's pipe handles which prevented the container from exiting.
  • Argument quoting complexity: The old cmd.exe /s /c wrapper on Windows required escapeJSON to add outer quotes that cmd.exe would strip. With shell: false, JSON.stringify values pass through unchanged.
  • Shell interpretation on Linux: shell: true on Linux causes # to be treated as a comment character, breaking values like #/workflows/give_kudos_workflow.

Preview

Behind the scenes, this is what happens when spawning a command:

Linux:

- /bin/sh -c "slack trigger run --workflow #/workflows/give_kudos_workflow"
+ execvp("slack", ["trigger", "run", "--workflow", "#/workflows/give_kudos_workflow"])

Windows:

- cmd.exe /s /c "slack trigger run --workflow #/workflows/give_kudos_workflow"
+ CreateProcessW("slack", ["trigger", "run", "--workflow", "#/workflows/give_kudos_workflow"])

Notes

📚 Reference: https://nodejs.org/api/child_process.html#child-processspawnsynccommand-args-options

Requirements

…iner hangs

In Windows Server Docker containers, processes hang when they inherit
Docker's entrypoint pipe handles. Using cmd.exe (via shell:true or the
explicit /s /c wrapper) triggers this issue. This change spawns the CLI
binary directly on Windows with shell:false.

Also simplifies escapeJSON in datastore commands since outer quote
wrapping is no longer needed without cmd.exe consuming them.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 6, 2026

🦋 Changeset detected

Latest commit: 67559ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@slack/cli-test Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.52%. Comparing base (e8a087c) to head (67559ab).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2582      +/-   ##
==========================================
+ Coverage   87.50%   87.52%   +0.02%     
==========================================
  Files          62       62              
  Lines       10256    10228      -28     
  Branches      418      418              
==========================================
- Hits         8974     8952      -22     
+ Misses       1260     1254       -6     
  Partials       22       22              
Flag Coverage Δ
cli-hooks 87.52% <66.66%> (+0.02%) ⬆️
cli-test 87.52% <66.66%> (+0.02%) ⬆️
logger 87.52% <66.66%> (+0.02%) ⬆️
oauth 87.52% <66.66%> (+0.02%) ⬆️
socket-mode 87.52% <66.66%> (+0.02%) ⬆️
web-api 87.52% <66.66%> (+0.02%) ⬆️
webhook 87.52% <66.66%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

zimeg and others added 3 commits May 6, 2026 09:55
The generic env parameter tests hardcoded shell:true but on Windows
it's now shell:false. Use process.platform to set the expected value.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Using shell:true causes issues with special characters like # being
interpreted as comments. Spawning the CLI binary directly with
shell:false avoids both the Windows Docker hang and the need for
outer-quote hacks to protect shell metacharacters.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
- Remove redundant platform if-branch in getSpawnArguments (both paths
  were identical after shell:false change)
- Inline escapeJSON as JSON.stringify at call sites
- Inline expectedShell constant directly in test assertions

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg
Copy link
Copy Markdown
Member Author

zimeg commented May 6, 2026

🔮 🚀 Will make an RC from this branch for testing purposes!

zimeg and others added 4 commits May 6, 2026 13:24
The Go CLI flag parser fails to receive values starting with # (like
#/workflows/give_kudos_workflow) when passed as direct argv entries via
shell:false on Linux. Reverting to shell:true on non-Windows with
single-quote escaping for each argument protects special characters.

Windows retains shell:false to avoid Docker pipe handle inheritance hangs.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
shell:false passes args directly to the process without any shell
interpretation. This is simpler and avoids the need for quoting
special characters like #. The original shell:true + cmd.exe workaround
was only needed because child_process strips quotes when using a shell.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg changed the title fix(cli-test): remove cmd.exe wrapping on Windows fix(cli-test): use shell:false to spawn CLI directly without a shell May 7, 2026
@zimeg zimeg added the pkg:cli-test applies to `@slack/cli-test` label May 7, 2026
@zimeg zimeg added this to the cli-test@next milestone May 7, 2026
@zimeg zimeg added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch labels May 7, 2026
@zimeg zimeg self-assigned this May 7, 2026
@zimeg zimeg changed the title fix(cli-test): use shell:false to spawn CLI directly without a shell fix(cli-test): invoke commands without shell intermediate May 7, 2026
Copy link
Copy Markdown
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👾 Another quick blurb if that's alright?

Comment thread packages/cli-test/package.json Outdated
Co-authored-by: Eden Zimbelman <zim@o526.net>
@zimeg zimeg marked this pull request as ready for review May 7, 2026 15:10
@zimeg zimeg requested a review from a team as a code owner May 7, 2026 15:10
@zimeg
Copy link
Copy Markdown
Member Author

zimeg commented May 7, 2026

🚢 Let's get this merged now for improvements to what we can test! I'll merge this now!

@zimeg zimeg merged commit 3c4e927 into main May 7, 2026
11 of 12 checks passed
@zimeg zimeg deleted the zimeg-cli-test-fix-windows branch May 7, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented pkg:cli-test applies to `@slack/cli-test` semver:patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant