{"record":{"id":"ea02ad462d511190","repo":"testcontainers/testcontainers-java","slug":"version-is-not-a-semantic-version-the-function-withdatabase","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/containers/Neo4jContainer.java","lineNumber":356,"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 S withRandomPassword() {\n        return withAdminPassword(UUID.randomUUID().toString());\n    }\n}\n","sourceCodeStart":338,"sourceCodeEnd":370,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java#L338-L370","documentation":"isNeo4jDatabaseVersionSupportingDbCopy determines whether withDatabase() can copy the default database to a new named database. Database copy is only supported on Neo4j 3.5.x; if the image's version string is not a semantic version, the check cannot confirm support, logs this warning (db copy will fail), plus a note that copying is only supported for 3.5.x, and returns false so withDatabase will not attempt the copy path.","triggerScenarios":"Calling neo4j.withDatabase(\"mydb\") on a container whose image version tag is not semantic (e.g. neo4j:latest, neo4j:5-enterprise, custom builds) so usedComparableVersion.isSemanticVersion() is false.","commonSituations":"Using floating tags like neo4j:latest; enterprise/custom images tagged without strict semver; upgrading images while keeping withDatabase() calls written for 3.5.x.","solutions":["Pin a semver image tag; for db-copy support specifically use Neo4j 3.5.x (e.g. neo4j:3.5.35)","Remove withDatabase() and create/switch databases via Cypher in an init script for Neo4j 4+","Verify the tag parses as semantic version (major.minor.patch)"],"exampleFix":"// before\nnew Neo4jContainer(\"neo4j:latest\").withDatabase(\"mydb\");\n// after\nnew Neo4jContainer(\"neo4j:3.5.35\").withDatabase(\"mydb\");","handlingStrategy":"validation","validationCode":"String tag = image.getVersionPart();\nboolean semver = tag.matches(\"\\\\d+\\\\.\\\\d+\\\\.\\\\d+.*\");\nif (!semver || !tag.startsWith(\"3.5\")) {\n    // withDatabase() db-copy will not work; plan an init-script alternative\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use withDatabase() on Neo4j 3.5.x images pinned with semver tags","Avoid 'latest' or custom non-semver tags when relying on version-dependent features","Provision databases via Cypher init scripts for Neo4j 4+"],"tags":["neo4j","versioning","database-copy","testcontainers"],"backgroundTag":"invalid-config-value","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"}