{"record":{"id":"1a330419448b7ba6","repo":"testcontainers/testcontainers-java","slug":"no-explicit-version-tag-was-provided-in-jdbc-url-and-this","errorCode":null,"errorMessage":"No explicit version tag was provided in JDBC URL and this class ({}) does not override newInstance() to set a default tag. `latest` will be used but results may be unreliable!","messagePattern":"No explicit version tag was provided in JDBC URL and this class \\((.+?)\\) does not override newInstance\\(\\) to set a default tag\\. `latest` will be used but results may be unreliable!","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainerProvider.java","lineNumber":28,"sourceCode":" */\n@Slf4j\npublic abstract class JdbcDatabaseContainerProvider {\n\n    /**\n     * Tests if the specified database type is supported by this Container Provider. It should match to the base image name.\n     * @param databaseType {@link String}\n     * @return <code>true</code> when provider can handle this database type, else <code>false</code>.\n     */\n    public abstract boolean supports(String databaseType);\n\n    /**\n     * Instantiate a new {@link JdbcDatabaseContainer} without any specified image tag. Subclasses <i>should</i>\n     * override this method if possible, to provide a default tag that is more stable than <code>latest</code>`.\n     *\n     * @return Instance of {@link JdbcDatabaseContainer}\n     */\n    public JdbcDatabaseContainer newInstance() {\n        log.warn(\n            \"No explicit version tag was provided in JDBC URL and this class ({}) does not \" +\n            \"override newInstance() to set a default tag. `latest` will be used but results may \" +\n            \"be unreliable!\",\n            this.getClass().getCanonicalName()\n        );\n        return this.newInstance(\"latest\");\n    }\n\n    /**\n     * Instantiate a new {@link JdbcDatabaseContainer} with specified image tag.\n     * @param tag\n     * @return Instance of {@link JdbcDatabaseContainer}\n     */\n    public abstract JdbcDatabaseContainer newInstance(String tag);\n\n    /**\n     * Instantiate a new {@link JdbcDatabaseContainer} using information provided with {@link ConnectionUrl}.\n     * @param url {@link ConnectionUrl}","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainerProvider.java#L10-L46","documentation":"When a JDBC URL like jdbc:tc:postgresql:///db omits a version tag, Testcontainers asks the matching JdbcDatabaseContainerProvider to create a container. If the provider subclass does not override the no-arg newInstance() to supply a stable default tag, the base implementation logs this warning and falls back to the floating 'latest' image tag. Because 'latest' points at whatever was most recently pushed, builds can break or behave differently over time, hence the unreliability warning.","triggerScenarios":"Calling Driver.connect with a jdbc:tc: URL lacking a :tag segment (e.g. jdbc:tc:postgresql:16-alpine is fine, jdbc:tc:postgresql://localhost/databasename is not) where the database provider class only implements newInstance(String tag) and not newInstance().","commonSituations":"Upgrading testcontainers and switching to a database whose provider stopped defaulting a tag; copy-pasting a JDBC URL without an image version; CI pulls a different 'latest' image than a teammate's machine, causing flaky schema/behavior differences.","solutions":["Add an explicit version tag to the JDBC URL, e.g. jdbc:tc:postgresql:16.2:///mydb","Override newInstance() in the custom JdbcDatabaseContainerProvider subclass to return newInstance(\"<stable-tag>\")","Pin a DockerImageName/image version via container-specific configuration if using the container API directly instead of the driver"],"exampleFix":"// before (provider)\npublic class MyDbProvider extends JdbcDatabaseContainerProvider {\n    public JdbcDatabaseContainer newInstance(String tag) { return new MyDbContainer(tag); }\n}\n// after\npublic class MyDbProvider extends JdbcDatabaseContainerProvider {\n    @Override\n    public JdbcDatabaseContainer newInstance() { return newInstance(\"16.2\"); }\n    public JdbcDatabaseContainer newInstance(String tag) { return new MyDbContainer(tag); }\n}","handlingStrategy":"validation","validationCode":"// Prefer explicit tags in URLs\nif (!jdbcUrl.matches(\"jdbc:tc:[^:]+:[^:]+:.*\")) {\n    throw new IllegalArgumentException(\"JDBC URL must pin an image version, e.g. jdbc:tc:postgresql:16:///db\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a version tag in jdbc:tc: URLs","When writing custom providers, override the no-arg newInstance() with a stable default tag","Watch test logs for this warning in CI and treat it as a build smell"],"tags":["jdbc","versioning","docker-image","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"}