{"record":{"id":"1de12bd7e2ea84fd","repo":"elastic/elasticsearch","slug":"cannot-set-elasticsearch-distribution-type-to-ty","errorCode":null,"errorMessage":"Cannot set Elasticsearch Distribution type to ${type}. Type unknown.","messagePattern":"Cannot set Elasticsearch Distribution type to (.+?)\\. Type unknown\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java","lineNumber":134,"sourceCode":"\n    public ElasticsearchDistributionType getType() {\n        return type.get();\n    }\n\n    public void setType(ElasticsearchDistributionType type) {\n        this.type.set(type);\n    }\n\n    /**\n     * For simplicity only public distribution types are supported here\n     * */\n    public void setType(String type) {\n        if (type.equals(ElasticsearchDistributionTypes.ARCHIVE.getName())) {\n            this.type.set(ElasticsearchDistributionTypes.ARCHIVE);\n        } else if (type.equals(ElasticsearchDistributionTypes.INTEG_TEST_ZIP.getName())) {\n            this.type.set(ElasticsearchDistributionTypes.INTEG_TEST_ZIP);\n        } else {\n            throw new IllegalArgumentException(\"Cannot set Elasticsearch Distribution type to \" + type + \". Type unknown.\");\n        }\n    }\n\n    public boolean getBundledJdk() {\n        return bundledJdk.getOrElse(true);\n    }\n\n    public boolean isDocker() {\n        return this.type.get().isDocker();\n    }\n\n    public void setBundledJdk(Boolean bundledJdk) {\n        this.bundledJdk.set(bundledJdk);\n    }\n\n    public boolean getFailIfUnavailable() {\n        return this.failIfUnavailable.get();\n    }","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java#L116-L152","documentation":"ElasticsearchDistribution.setType(String) only recognises the names of ARCHIVE and INTEG_TEST_ZIP because, per its javadoc, only public distribution types are supported here. Any other string (docker, rpm, deb, or a typo) is rejected. The typed overload setType(ElasticsearchDistributionType) must be used for the other types.","triggerScenarios":"A build script calls distribution.setType(\"docker\") or setType(\"rpm\") instead of the typed enum overload, or passes a misspelled name like \"archive \" (trailing space) or \"integ-zip\".","commonSituations":"A contributor assumes the string overload covers all distribution types; a copy-paste from older API docs; trailing whitespace from a generated script.","solutions":["For docker/rpm/deb use the enum overload: distribution.setType(ElasticsearchDistributionTypes.DOCKER).","For archive/integ_test_zip ensure the string exactly matches ElasticsearchDistributionTypes.<TYPE>.getName().","Trim and verify the spelling against the enum constant."],"exampleFix":"// before\ndistribution.setType('docker')\n// after\nimport org.elasticsearch.gradle.distribution.ElasticsearchDistributionTypes\ndistribution.setType(ElasticsearchDistributionTypes.DOCKER)","handlingStrategy":"validation","validationCode":"static ElasticsearchDistributionType resolveType(String name) {\n    for (ElasticsearchDistributionType t : ElasticsearchDistributionTypes.values()) {\n        if (t.getName().equals(name)) return t;\n    }\n    throw new IllegalArgumentException(\"Unknown distribution type name: \" + name);\n}\ndistribution.setType(resolveType(typeName));","typeGuard":"static boolean isKnownTypeName(String name) {\n    return Arrays.stream(ElasticsearchDistributionTypes.values())\n        .map(ElasticsearchDistributionType::getName).anyMatch(name::equals);\n}","tryCatchPattern":null,"preventionTips":["Prefer the enum overload setType(ElasticsearchDistributionType) over the string overload.","Validate the string against ElasticsearchDistributionTypes values before passing.","Trim whitespace from generated type names."],"tags":["gradle","distribution","validation","build-script"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}