testcontainers / testcontainers/testcontainers-java
DockerComposeContainer - InvalidExitException stack trace and cause hidden
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
While attempting to use the DockerComposeContainer, I was having some difficulty troubleshooting a startup exception, and had to switch to using individual GenericContainer definitions to figure out that the root cause was failure to find an image.
This was made difficult by the fact that InvalidExitExceptions are caught and mapped to a ContainerLaunchException, but without the causing exception being wrapped.
} catch (InvalidExitValueException e) {
throw new ContainerLaunchException("Local Docker Compose exited abnormally with code " +
e.getExitValue() + " whilst running command: " + cmd);
} catch (Exception e) {
throw new ContainerLaunchException("Error running local Docker Compose command: " + cmd, e);
}
Is there a reason that the original exception is not included in the ContainerLaunchException?
I was experiencing this issue only while running a maven build which by default hides logs, and while that could probably be tweaked by config to debug it, it seems like supporting this could be easily improved by simply wrapping the exception like so, the same way it is for generic Exception:
} catch (InvalidExitValueException e) {
throw new ContainerLaunchException("Local Docker Compose exited abnormally with code " +
e.getExitValue() + " whilst running command: " + cmd, e);
} catch (Exception e) {
throw new ContainerLaunchException("Error running local Docker Compose command: " + cmd, e);
}
Contributor 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.
Research direction
Start in core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java at lines 771-775, where InvalidExitValueException is converted to ContainerLaunchException. Run the relevant Docker Compose tests and verify that the original exception is preserved as the cause when the launch fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, java
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100