Stop splitting string commands on spaces in `exec`
Maintainers usually reply within 4 days
@Mario-Mohar is already working on this.
Since Oct 30, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, node.js, typescript
Research direction
Start at exec in packages/testcontainers/src/generic/started-generic.ts and compare how its string and array forms build arguments. Then inspect the Redis and Valkey call sites named in the issue, and coordinate the string overload deprecation with #1518. Done means commands with spaces are passed as intended, both module calls use the array form, and the relevant tests cover the behavior.
Written by the indexing model from the issue text.
Description
What happens
exec accepts string | string[]. The string form is turned into arguments with command.split(" "), so quoting is not honoured and any argument containing a space is broken up.
await container.exec('sh -c "echo hello world"');
// exitCode: 2
// stderr: hello: line 1: syntax error: unterminated quoted string
await container.exec(["sh", "-c", "echo hello world"]);
// exitCode: 0
// stdout: hello world
Two modules use the string form with an interpolated value:
packages/modules/redis/src/redis-container.ts:container.exec(`/tmp/import.sh ${this.password}`)packages/modules/valkey/src/valkey-container.ts:container.exec(`/tmp/import.sh ${this.password || ""}`)
A password containing a space is split into separate arguments (from reading the code).
Expected
A command is never split on spaces. Either the string form goes away, or it is parsed with shell quoting rules.
Where
exec in packages/testcontainers/src/generic-container/started-generic-container.ts.
Notes
- Java (
execInContainer(String... command)) and Go (Exec(ctx, cmd []string, ...)) accept only an argument list. - The docs only show the array form.
- Switch the redis and valkey calls to the array form either way.
- Semver: labelled
minorfor deprecating the string overload, with removal in a later major. - Reproduced on
main(aa60a746, 12.2.0) with Docker 29.6.1.
Dependencies
- Nothing blocks this. It can start now.
- Coordinate with #1518: for how the string overload is deprecated.
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 290
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 22
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from testcontainers/testcontainers-node
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
testcontainers/testcontainers-node#1673 ·
Maintainers usually reply within 4 days
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
testcontainers/testcontainers-node#1539 ·
Maintainers usually reply within 4 days
-
Let `Wait.forListeningPorts()` wait on specific portsPossibly taken @artbom claimed this 29 days ago. Openenhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testcontainers/testcontainers-node#1533 ·
Maintainers usually reply within 4 days
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
testcontainers/testcontainers-node#1531 ·
Maintainers usually reply within 4 days
-
Export the types used in public method signaturesPossibly taken @artbom claimed this 29 days ago. Openenhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-node#1528 ·
Maintainers usually reply within 4 days
All issues in testcontainers/testcontainers-node
Similar issues
-
prio:low scope:hud
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OliverRomhagen/vrigstad-joyride#953 ·
Maintainers usually reply within 1 day
-
review-followup
Difficulty 1/5 Under an hour Newbie friendliness 92/100
griffinwork40/agent-afk#5446 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
kacper-szewczyk/Ticknest#346 ·
Maintainers usually reply within 1 day
-
echarts geo: a GeoJSON URL that returns 200 with a body that is not JSON is fetched on each refreshOpenbug plugin/echarts/geo
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Yeachan-Heo/gajae-code#8230 ·
Maintainers usually reply within 1 day