{"record":{"id":"1cd2e2b4e6d08c77","repo":"testcontainers/testcontainers-java","slug":"path-already-configured-for-copy-mountablefile","errorCode":null,"errorMessage":"Path already configured for copy: ${mountableFile}","messagePattern":"Path already configured for copy: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/testcontainers/containers/GenericContainer.java","lineNumber":1265,"sourceCode":"        return self();\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    @Override\n    public SELF withWorkingDirectory(String workDir) {\n        this.setWorkingDirectory(workDir);\n        return self();\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    @Override\n    public SELF withCopyFileToContainer(MountableFile mountableFile, String containerPath) {\n        if (copyToFileContainerPathMap.containsKey(mountableFile)) {\n            throw new IllegalStateException(\"Path already configured for copy: \" + mountableFile);\n        }\n        copyToFileContainerPathMap.put(mountableFile, containerPath);\n        return self();\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    @Override\n    public SELF withCopyToContainer(Transferable transferable, String containerPath) {\n        copyToTransferableContainerPathMap.put(transferable, containerPath);\n        return self();\n    }\n\n    /**\n     * Get the IP address that this container may be reached on (may not be the local machine).\n     *\n     * @return an IP address","sourceCodeStart":1247,"sourceCodeEnd":1283,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/containers/GenericContainer.java#L1247-L1283","documentation":"Guard in GenericContainer.withCopyFileToContainer: the same MountableFile source was already registered in copyToFileContainerPathMap, i.e. a duplicate copy of the same path was configured. Testcontainers forbids configuring the same source for copy twice, so an IllegalStateException is thrown naming the offending file.","triggerScenarios":"Thrown at core/src/main/java/org/testcontainers/containers/GenericContainer.java:1265 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call withCopyFileToContainer only once per unique MountableFile source","Remove duplicate copy registrations of the same path from container setup"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}