elastic/elasticsearch · error · UnsupportedOperationException
distribution type [${typeName}] for elasticsearch distributi
Error message
distribution type [${typeName}] for elasticsearch distribution [${name}] cannot be extracted What it means
getExtracted returns the extracted (unpacked) artifact file collection, but only for distribution types whose shouldExtract() is true (archive/integ_test_zip). For docker/rpm/deb the distribution is consumed in place, so calling getExtracted is unsupported and throws UnsupportedOperationException naming the type and distribution.
Source
Thrown at build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java:199
* freezes the distribution configuration and
* runs distribution finalizer logic.
*/
public ElasticsearchDistribution maybeFreeze() {
if (frozen == false) {
finalizeValues();
frozen = true;
}
return this;
}
public String getFilepath() {
maybeFreeze();
return configuration.getSingleFile().toString();
}
public ConfigurableFileCollection getExtracted() {
if (getType().shouldExtract() == false) {
throw new UnsupportedOperationException(
"distribution type [" + getType().getName() + "] for " + "elasticsearch distribution [" + name + "] cannot be extracted"
);
}
return extracted;
}
@Override
public TaskDependency getBuildDependencies() {
if (skippingDockerDistributionBuild()) {
return task -> Collections.emptySet();
} else {
maybeFreeze();
return getType().shouldExtract() && (preferArchive.get() == false)
? extracted.getBuildDependencies()
: configuration.getBuildDependencies();
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Guard the call: only invoke getExtracted() when getType().shouldExtract() is true.
- For non-extractable types use iterator() / getBuildDependencies() which handle both branches.
- Split your task into an extract-consumer and an archive-consumer variant.
Example fix
// before def files = distribution.getExtracted() // throws for docker // after def files = distribution.getType().shouldExtract() ? distribution.getExtracted() : distribution.configuration
Defensive patterns
Strategy: type-guard
Validate before calling
if (!distribution.getType().shouldExtract()) {
throw new IllegalArgumentException("Distribution " + distribution.getName() + " type " + distribution.getType() + " is not extractable");
} Type guard
static boolean isExtractable(ElasticsearchDistribution d) {
return d.getType().shouldExtract();
} Try / catch
try {
return distribution.getExtracted();
} catch (UnsupportedOperationException e) {
if (e.getMessage().contains("cannot be extracted")) {
return distribution.configuration; // fallback for non-extractable types
}
throw e;
} Prevention
- Always branch on getType().shouldExtract() before calling getExtracted().
- Use iterator() for generic consumption across all distribution types.
- Document which of your tasks assume an extractable type.
When it happens
Trigger: Calling distribution.getExtracted() on a distribution whose getType().shouldExtract() is false — i.e. one configured as DOCKER, RPM, or DEB.
Common situations: A task wired to consume the extracted dir is reused against a docker/rpm/deb distribution; a plugin assumes all distributions are extractable; a test helper generic across types.
Related errors
- Cannot set Elasticsearch Distribution type to ${type}. Type
- platform cannot be set on elasticsearch distribution [${name
- bundledJdk cannot be set on elasticsearch distribution [${na
- failIfUnavailable cannot be 'false' on elasticsearch distrib
- Expecting project name containing 'zip' or 'tar'.
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/4e28be1d5d6c793f.
Report an issue: GitHub.