{"record":{"id":"7ad7e776a807cc19","repo":"testcontainers/testcontainers-java","slug":"collection-name-must-not-be-empty-solrcontainer","errorCode":null,"errorMessage":"Collection name must not be empty","messagePattern":"Collection name must not be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/solr/src/main/java/org/testcontainers/solr/SolrContainer.java","lineNumber":63,"sourceCode":"    public SolrContainer(final DockerImageName dockerImageName) {\n        super(dockerImageName);\n        dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);\n\n        waitingFor(\n            Wait.forLogMessage(\".*o\\\\.e\\\\.j\\\\.s\\\\.Server Started.*\", 1).withStartupTimeout(Duration.ofMinutes(1))\n        );\n        this.configuration = new SolrContainerConfiguration();\n        this.imageVersion = new ComparableVersion(dockerImageName.getVersionPart());\n    }\n\n    public SolrContainer withZookeeper(boolean zookeeper) {\n        configuration.setZookeeper(zookeeper);\n        return self();\n    }\n\n    public SolrContainer withCollection(String collection) {\n        if (StringUtils.isEmpty(collection)) {\n            throw new IllegalArgumentException(\"Collection name must not be empty\");\n        }\n        configuration.setCollectionName(collection);\n        return self();\n    }\n\n    public SolrContainer withConfiguration(String name, URL solrConfig) {\n        if (StringUtils.isEmpty(name) || solrConfig == null) {\n            throw new IllegalArgumentException();\n        }\n        configuration.setConfigurationName(name);\n        configuration.setSolrConfiguration(solrConfig);\n        return self();\n    }\n\n    public SolrContainer withSchema(URL schema) {\n        configuration.setSolrSchema(schema);\n        return self();\n    }","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/solr/src/main/java/org/testcontainers/solr/SolrContainer.java#L45-L81","documentation":"SolrContainer.withCollection validates that the collection/core name is non-empty before storing it in the configuration. An empty (or null, via StringUtils.isEmpty) name is rejected with IllegalArgumentException because Solr cannot create a nameless core.","triggerScenarios":"Calling withCollection(\"\") or withCollection(null), often when the name comes from an unset config property or environment variable.","commonSituations":"Collection name read from a properties/YAML file that is missing the key, or built by string concatenation that yields \"\".","solutions":["Pass a non-empty literal collection name to withCollection.","Check the config source supplying the name and give it a default value.","Validate the name in your test setup before constructing the container."],"exampleFix":"// before\ncontainer.withCollection(System.getProperty(\"solr.collection\"));\n// after\nString collection = System.getProperty(\"solr.collection\", \"testcollection\");\ncontainer.withCollection(collection);","handlingStrategy":"validation","validationCode":"if (collection == null || collection.isEmpty()) throw new IllegalArgumentException(\"Solr collection name must not be empty\");\ncontainer.withCollection(collection);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass names straight from config properties without a default/empty check.","Centralize container construction so the name is validated once."],"tags":["solr","testcontainers","argument-validation"],"backgroundTag":"empty-required-field","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"}