{"record":{"id":"5cce4c9d4603f00d","repo":"testcontainers/testcontainers-java","slug":"cannot-use-enterprise-version-with-alternative-image-s","errorCode":null,"errorMessage":"Cannot use enterprise version with alternative image %s.","messagePattern":"Cannot use enterprise version with alternative image (.+?)\\.","errorType":"validation","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java","lineNumber":222,"sourceCode":"    /**\n     * @return URL of the transactional HTTPS endpoint.\n     */\n    public String getHttpsUrl() {\n        return String.format(\"https://\" + getHost() + \":\" + getMappedPort(DEFAULT_HTTPS_PORT));\n    }\n\n    /**\n     * Configures the container to use the enterprise edition of the default docker image.\n     * <br><br>\n     * Please have a look at the <a href=\"https://neo4j.com/licensing/\">Neo4j Licensing page</a>. While the Neo4j\n     * Community Edition can be used for free in your projects under the GPL v3 license, Neo4j Enterprise edition\n     * needs either a commercial, education or evaluation license.\n     *\n     * @return This container.\n     */\n    public S withEnterpriseEdition() {\n        if (!standardImage) {\n            throw new IllegalStateException(\n                String.format(\"Cannot use enterprise version with alternative image %s.\", getDockerImageName())\n            );\n        }\n\n        setDockerImageName(DEFAULT_IMAGE_NAME.withTag(ENTERPRISE_TAG).asCanonicalNameString());\n        LicenseAcceptance.assertLicenseAccepted(getDockerImageName());\n\n        addEnv(\"NEO4J_ACCEPT_LICENSE_AGREEMENT\", \"yes\");\n\n        return self();\n    }\n\n    /**\n     * Sets the admin password for the default account (which is <pre>neo4j</pre>). A null value or an empty string\n     * disables authentication.\n     *\n     * @param adminPassword The admin password for the default database account.\n     * @return This container.","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java#L204-L240","documentation":"Neo4jContainer.withEnterpriseEdition() only supports upgrading the official Neo4j Docker image to its enterprise tag. If you set a custom/alternative image (e.g. via withImage or a custom docker image name), the container cannot safely derive an enterprise variant, so an IllegalStateException is thrown instead of producing a broken image name.","triggerScenarios":"Calling withEnterpriseEdition() after setting a non-default Docker image (standardImage == false), e.g. container.withImage(\"mycompany/neo4j\").withEnterpriseEdition().","commonSituations":"Teams pointing at a private registry mirror or custom-built Neo4j image and then trying to enable enterprise features; mixing image customization helpers with withEnterpriseEdition().","solutions":["Use the default Neo4j image and rely on withEnterpriseEdition() to switch the tag to enterprise.","If you need a custom registry, build the full enterprise image name yourself (registry/neo4j:<version>-enterprise) and set it directly instead of calling withEnterpriseEdition().","Remove the withEnterpriseEdition() call if you already use a community custom image."],"exampleFix":"// before\nnew Neo4jContainer<>(\"my.registry/neo4j:5.12\").withEnterpriseEdition();\n// after\nnew Neo4jContainer<>(\"neo4j:5.12-enterprise\");","handlingStrategy":"validation","validationCode":"if (!container.getDockerImageName().startsWith(\"neo4j:\")) {\n    throw new IllegalStateException(\"withEnterpriseEdition() requires the default neo4j image\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    container.withEnterpriseEdition();\n} catch (IllegalStateException e) {\n    // fall back to explicit enterprise image name\n    container = new Neo4jContainer<>(\"neo4j:\" + version + \"-enterprise\");\n}","preventionTips":["Only combine withEnterpriseEdition() with the default image.","For custom registries, specify the full -enterprise tag yourself.","Centralize Neo4j container factory code so image and edition options can't conflict."],"tags":["neo4j","docker-image","invalid-state-transition"],"backgroundTag":"conflicting-config-options","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"}