testcontainers-node icon indicating copy to clipboard operation
testcontainers-node copied to clipboard

TypeError: The "iterable" argument must be an instance of Iterable. Received an instance of Object

Open lucmoulin opened this issue 7 months ago • 1 comments

Hello team, I've the following configuration on Typescript:

const eannaContainer = await new GenericContainer(
    '<server name>/eanna/release:4.3.0')
    .withNetwork(network)
    .withNetworkAliases('eannahost')
    .withExposedPorts({
        container: 8080,
        host: 6080
    })
    .withCopyFilesToContainer(
        [{source: rootE2gFolderPath + '/config/eanna/logback-spring.xml', target: '/deployments/config/logback-spring.xml'}])
    .withEnvironment({
        ...eannaEnv,
        JAVA_MAX_MEM_RATIO: '100',
        JAVA_INIT_MEM_RATIO: '50'
    })
    .withStartupTimeout(300000) // wait 5 min
    .withWaitStrategy(Wait.forHttp('/actuator/health', 8080))
    .start();
But when I trigger it with our CI/CD pipeline, i get the following exception:
[21:33:27.404+02:00] - TypeError: The "iterable" argument must be an instance of Iterable. Received an instance of Object
[21:33:27.404+02:00] - at from (node:internal/streams/from:36:11)
[21:33:27.404+02:00] - at Function.Readable.from (node:internal/streams/readable:1729:10)
[21:33:27.404+02:00] - at DockerContainerClient.putArchive (/home/jenkins/agent/workspace/edossier2go-edossier/edossier2go-edossier-develop/build-deploy-test/angular-frontend/node_modules/.pnpm/[email protected]/node_modules/testcontainers/src/container-runtime/clients/container/docker-container-client.ts:78:37)
[21:33:27.404+02:00] - at processTicksAndRejections (node:internal/process/task_queues:105:5)

This bug has been introduced after the version 10.21.0 (it works for this version).

After analysis, the problem comes from the setup of the file to copy: withCopyFilesToContainer On my environment I've defined the following configuration:

.withCopyFilesToContainer(
[{source: rootE2gFolderPath + '/config/eanna/logback-spring.xml', target: '/deployments/config/logback-spring.xml'}])

Could you please double check in the code this piece of code:

if (this.filesToCopy.length > 0 || this.directoriesToCopy.length > 0 || this.contentsToCopy.length > 0) {
const archive = this.createArchiveToCopyToContainer();
archive.finalize();
await client.container.putArchive(container, archive, "/");
}

Thanks a lot Luc

lucmoulin avatar May 21 '25 05:05 lucmoulin

This code hasn't changed in two years:

https://github.com/testcontainers/testcontainers-node/blob/b31eaca1fd9d2599f0cd30e94b182ec0b765fff1/packages/testcontainers/src/generic-container/generic-container.ts#L181-L185

However, the dockerode dependency (client.container.putArchive) was upgraded from v3 to v4 in the 10.22.0 release.

What version of NodeJS are you using?

joebowbeer avatar May 23 '25 09:05 joebowbeer

Cannot reproduce. If it's still an issue please provide node/docker versions as per the issue template and I'll reopen.

cristianrgreco avatar Jul 23 '25 15:07 cristianrgreco