{"record":{"id":"bb2b63adbeed4c9c","repo":"testcontainers/testcontainers-java","slug":"version-is-not-a-semantic-version-the-function-withdatabase-bb2b63","errorCode":null,"errorMessage":"Version {} is not a semantic version. The function \"withDatabase\" will fail.","messagePattern":"Version (.+?) is not a semantic version\\. The function \"withDatabase\" will fail\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/neo4j/src/main/java/org/testcontainers/neo4j/Neo4jContainer.java","lineNumber":318,"sourceCode":"    private static String formatConfigurationKey(String plainConfigKey) {\n        final String prefix = \"NEO4J_\";\n\n        return String.format(\"%s%s\", prefix, plainConfigKey.replaceAll(\"_\", \"__\").replaceAll(\"\\\\.\", \"_\"));\n    }\n\n    private boolean isNeo4jDatabaseVersionSupportingDbCopy() {\n        String usedImageVersion = DockerImageName.parse(getDockerImageName()).getVersionPart();\n        ComparableVersion usedComparableVersion = new ComparableVersion(usedImageVersion);\n\n        boolean versionSupportingDbCopy =\n            usedComparableVersion.isLessThan(\"4.0\") && usedComparableVersion.isGreaterThanOrEqualTo(\"2\");\n\n        if (versionSupportingDbCopy) {\n            return true;\n        }\n        if (!usedComparableVersion.isSemanticVersion()) {\n            logger()\n                .warn(\n                    \"Version {} is not a semantic version. The function \\\"withDatabase\\\" will fail.\",\n                    usedImageVersion\n                );\n            logger().warn(\"Copying databases is only supported for Neo4j versions 3.5.x\");\n        }\n\n        return false;\n    }\n\n    public Neo4jContainer withRandomPassword() {\n        return withAdminPassword(UUID.randomUUID().toString());\n    }\n}\n","sourceCodeStart":300,"sourceCodeEnd":332,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/neo4j/src/main/java/org/testcontainers/neo4j/Neo4jContainer.java#L300-L332","documentation":"Neo4jContainer.isNeo4jDatabaseVersionSupportingDbCopy logs a warning when the Docker image version string cannot be parsed as a semantic version (major.minor.patch). Because db copy support is decided by comparing versions, an unparseable version means withDatabase (which relies on database copying) cannot be evaluated and will likely fail. The method then returns false.","triggerScenarios":"Using a Neo4j Docker image tag that is not a semantic version (e.g. 'latest', 'enterprise-nightly', '4.4' without patch) and calling withDatabase() on the container.","commonSituations":"Pointing at 'latest' or floating image tags; custom/renamed registry tags; enterprise images with suffixes that defeat version parsing.","solutions":["Pin the image to a full semantic version tag, e.g. neo4j:5.12.0 instead of neo4j:latest.","If using withDatabase(), verify the chosen version actually supports db copy (3.5.x).","Check the tag for unexpected suffixes and use the plain x.y.z portion."],"exampleFix":"// before\nnew Neo4jContainer(DockerImageName.parse(\"neo4j:latest\")).withDatabase(\"copyTarget\");\n// after\nnew Neo4jContainer(DockerImageName.parse(\"neo4j:3.5.22\")).withDatabase(\"copyTarget\");","handlingStrategy":"validation","validationCode":"String version = imageTag; // e.g. \"5.12.0\"\nif (!version.matches(\"^\\d+\\.\\d+\\.\\d+.*$\")) {\n    throw new IllegalArgumentException(\"Pin the Neo4j image to a semantic version, got: \" + version);\n}","typeGuard":"boolean isSemanticVersionTag(String tag) {\n    return tag != null && tag.matches(\"^\\d+\\.\\d+\\.\\d+.*$\");\n}","tryCatchPattern":null,"preventionTips":["Never use 'latest' or floating tags for Neo4j images in tests","Pin full x.y.z image tags","Verify withDatabase support before enabling db copy"],"tags":["neo4j","version-parsing","docker-image"],"backgroundTag":"invalid-argument-format","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"}