{"record":{"id":"e00c043aa787ffe8","repo":"testcontainers/testcontainers-java","slug":"consider-using-localstackcontainer-dockerimagename","errorCode":null,"errorMessage":"Consider using \"LocalStackContainer(DockerImageName dockerImageName, boolean legacyMode)\" constructor if you want to disable legacy mode.","messagePattern":"Consider using \"LocalStackContainer\\(DockerImageName dockerImageName, boolean legacyMode\\)\" constructor if you want to disable legacy mode\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"modules/localstack/src/main/java/org/testcontainers/containers/localstack/LocalStackContainer.java","lineNumber":176,"sourceCode":"\n        return true;\n    }\n\n    static boolean shouldRunInLegacyMode(String version) {\n        // assume that the latest images are up-to-date\n        // also consider images with extra packages (like latest-bigdata) and service-specific images (like s3-latest)\n        if (version.equals(\"latest\") || version.startsWith(\"latest-\") || version.endsWith(\"-latest\")) {\n            return false;\n        }\n\n        ComparableVersion comparableVersion = new ComparableVersion(version);\n        if (comparableVersion.isSemanticVersion()) {\n            boolean versionRequiresLegacyMode = comparableVersion.isLessThan(\"0.11\");\n            return versionRequiresLegacyMode;\n        }\n\n        log.warn(\"Version {} is not a semantic version, LocalStack will run in legacy mode.\", version);\n        log.warn(\n            \"Consider using \\\"LocalStackContainer(DockerImageName dockerImageName, boolean legacyMode)\\\" constructor if you want to disable legacy mode.\"\n        );\n        return true;\n    }\n\n    @Override\n    protected void configure() {\n        super.configure();\n\n        if (this.servicesEnvVarRequired) {\n            Preconditions.check(\"services list must not be empty\", !services.isEmpty());\n        }\n\n        if (!services.isEmpty()) {\n            withEnv(\"SERVICES\", services.stream().map(EnabledService::getName).collect(Collectors.joining(\",\")));\n            if (this.servicesEnvVarRequired) {\n                withEnv(\"EAGER_SERVICE_LOADING\", \"1\");\n            }","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/localstack/src/main/java/org/testcontainers/containers/localstack/LocalStackContainer.java#L158-L194","documentation":"Emitted immediately after the non-semantic-version warning in shouldRunInLegacyMode: Testcontainers falls back to legacy mode for LocalStack images whose tag it cannot parse, and suggests using the two-argument constructor LocalStackContainer(DockerImageName, boolean legacyMode) to explicitly choose the mode instead of relying on version inference. It is a hint, not a failure by itself; the resulting behavior change is that legacy mode is enabled.","triggerScenarios":"Same as the non-semantic version fallback: constructing LocalStackContainer with :latest/:nightly/custom tags; the single-arg (or default) constructor path cannot infer the mode and warns with this hint.","commonSituations":"Using floating image tags in CI; migrating code written for pre-0.11 LocalStack to modern images while keeping a non-semantic tag.","solutions":["Switch to new LocalStackContainer(DockerImageName.parse(\"localstack/localstack:X.Y.Z\"), false) to disable legacy mode explicitly","Pin a semantic version so mode inference works correctly","Verify expected behavior after the change: legacy mode changes env vars and single vs multiple container setup"],"exampleFix":"// before\nLocalStackContainer ls = new LocalStackContainer(DockerImageName.parse(\"localstack/localstack:latest\"));\n// after\nLocalStackContainer ls = new LocalStackContainer(DockerImageName.parse(\"localstack/localstack:latest\"), false);","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer the explicit two-arg constructor LocalStackContainer(image, legacyMode) over version inference","Migrate away from legacy-mode-only configuration when moving to modern LocalStack images","Treat this hint in logs as a prompt to make image tags deterministic"],"tags":["localstack","deprecated-api-usage","versioning","testcontainers"],"backgroundTag":"deprecated-api-usage","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"}