question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] GenericContainer doesn’t properly split commands

See original GitHub issue

Module

Core

Testcontainers version

1.17.3

Using the latest Testcontainers version?

Yes

Host OS

ALL

Host Arch

ALL

Docker version

N/A

What happened?

GenericContainer setCommand uses Java String split to build the array of command parts. If the command contains quoted arguments/quoted arguments with escaped quotes, the container fails.

Example command:

/bin/sh test.sh “argument 1” “argument 2”

Relevant log output

No response

Additional Information

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dhoardcommented, Sep 15, 2022

@REslim30 Thanks for the insight. I can see where non-POSIX commands could be a probably.

I currently have a workaround in place, so it’s not blocking me.

0reactions
REslim30commented, Sep 24, 2022

It actually might be a shell thing. From man bash

DEFINITIONS
       The following definitions are used throughout the rest of this document.
       blank  A space or tab.
       word   A sequence of characters considered as a single unit by the shell.  Also known as a token.
       name   A word consisting only of alphanumeric characters and underscores, and beginning with an alphabetic character or an underscore.  Also referred to as an iden-
              tifier.
       metacharacter
              A character that, when unquoted, separates words.  One of the following:
              |  & ; ( ) < > space tab newline
QUOTING
       Quoting is used to remove the special meaning of certain characters or words to the shell.  Quoting can be used to disable special treatment for special characters,
       to prevent reserved words from being recognized as such, and to prevent parameter expansion.

       Each of the metacharacters listed above under DEFINITIONS has special meaning to the shell and must be quoted if it is to represent itself.

       When the command history expansion facilities are being used (see HISTORY EXPANSION below), the history expansion character, usually !, must be  quoted  to  prevent
       history expansion.

       There are three quoting mechanisms: the escape character, single quotes, and double quotes.
...
Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · testcontainers/testcontainers-java - GitHub
[Bug]: PostgreSQLContainer fails to startup intermittently under GitHub Actions (not ... [Bug] GenericContainer doesn't properly split commands type/bug.
Read more >
GenericContainer (TestContainers Core 1.3.0 API) - Javadoc.io
Convenience class with access to non-public members of GenericContainer. ... Run a command inside a running container, as though using "docker exec".
Read more >
Gitlab runner dind service cannot be used with Testcontainers
To work around this issue, I've had to have two stages, one to do the maven commands directly, and then another stage to...
Read more >
Deprecate Shell.GenericContainer (!153) · Merge requests
Turns out that this MR doesn't break it -- it is already non-functional in master. And I don't want to pollute this already...
Read more >
Micronaut Framework/questions - Gitter
Hi, I'm using micronaut 3.7.4 which doesn't appear to have the latest micronaut openapi version so apologize if fixed. I have some @Controllers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found