{"record":{"id":"ff1a61e0a410141e","repo":"testcontainers/testcontainers-java","slug":"changing-startup-timeout-is-not-supported-with-mode-s","errorCode":null,"errorMessage":"Changing startup timeout is not supported with mode %s","messagePattern":"Changing startup timeout is not supported with mode (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/testcontainers/containers/wait/strategy/WaitAllStrategy.java","lineNumber":82,"sourceCode":"    private void waitUntilNestedStrategiesAreReady(WaitStrategyTarget waitStrategyTarget) {\n        for (WaitStrategy strategy : strategies) {\n            strategy.waitUntilReady(waitStrategyTarget);\n        }\n    }\n\n    public WaitAllStrategy withStrategy(WaitStrategy strategy) {\n        if (mode == Mode.WITH_OUTER_TIMEOUT) {\n            applyStartupTimeout(strategy);\n        }\n\n        this.strategies.add(strategy);\n        return this;\n    }\n\n    @Override\n    public WaitAllStrategy withStartupTimeout(Duration startupTimeout) {\n        if (mode == Mode.WITH_INDIVIDUAL_TIMEOUTS_ONLY) {\n            throw new IllegalStateException(\n                String.format(\n                    \"Changing startup timeout is not supported with mode %s\",\n                    Mode.WITH_INDIVIDUAL_TIMEOUTS_ONLY\n                )\n            );\n        }\n\n        this.timeout = startupTimeout;\n        strategies.forEach(this::applyStartupTimeout);\n        return this;\n    }\n\n    private void applyStartupTimeout(WaitStrategy childStrategy) {\n        childStrategy.withStartupTimeout(this.timeout);\n    }\n}\n","sourceCodeStart":64,"sourceCodeEnd":99,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/containers/wait/strategy/WaitAllStrategy.java#L64-L99","documentation":"WaitAllStrategy in Mode.WITH_INDIVIDUAL_TIMEOUTS_ONLY lets each inner wait strategy own its timeout; the outer strategy therefore forbids overriding a global one. Calling withStartupTimeout on such an instance throws this IllegalStateException at configuration time (before any container starts).","triggerScenarios":"new WaitAllStrategy<>(WaitAllStrategy.Mode.WITH_INDIVIDUAL_TIMEOUTS_ONLY).withStartupTimeout(Duration.ofSeconds(90)) — or builder chaining that applies withStartupTimeout after selecting that mode.","commonSituations":"Copy-pasting a shared wait-strategy builder that always sets withStartupTimeout; switching the mode constant without removing the timeout call; combining per-strategy timeouts configured on children with an accidental global one.","solutions":["Remove the withStartupTimeout call and set timeouts on each child strategy instead","Use WaitAllStrategy.Mode.WITH_OUTER_TIMEOUT (default) if you want a single global timeout","Wrap construction in your own helper so the timeout call is only applied for compatible modes"],"exampleFix":"// before\nnew WaitAllStrategy<>(WaitAllStrategy.Mode.WITH_INDIVIDUAL_TIMEOUTS_ONLY)\n    .withStrategy(new HttpWaitStrategy().withStartupTimeout(Duration.ofSeconds(30)))\n    .withStartupTimeout(Duration.ofSeconds(90));\n// after\nnew WaitAllStrategy<>(WaitAllStrategy.Mode.WITH_INDIVIDUAL_TIMEOUTS_ONLY)\n    .withStrategy(new HttpWaitStrategy().withStartupTimeout(Duration.ofSeconds(30)));","handlingStrategy":"validation","validationCode":"WaitAllStrategy<WaitStrategy> s = new WaitAllStrategy<>(WaitAllStrategy.Mode.WITH_INDIVIDUAL_TIMEOUTS_ONLY);\n// Only call withStartupTimeout when the mode permits it\nif (mode != WaitAllStrategy.Mode.WITH_INDIVIDUAL_TIMEOUTS_ONLY) {\n    s.withStartupTimeout(Duration.ofSeconds(90));\n}","typeGuard":null,"tryCatchPattern":"try {\n    return allStrategy.withStartupTimeout(timeout);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Changing startup timeout is not supported\")) {\n        return allStrategy; // keep per-child timeouts\n    }\n    throw e;\n}","preventionTips":["Set timeouts on child strategies when using WITH_INDIVIDUAL_TIMEOUTS_ONLY","Never chain a shared builder that unconditionally calls withStartupTimeout","Default mode (WITH_OUTER_TIMEOUT) is the safe choice when you want one global timeout"],"tags":["configuration","wait-strategy","illegal-state","timeout","testcontainers"],"backgroundTag":"unsupported-operation","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}