{"record":{"id":"4e28be1d5d6c793f","repo":"elastic/elasticsearch","slug":"distribution-type-typename-for-elasticsearch","errorCode":null,"errorMessage":"distribution type [${typeName}] for elasticsearch distribution [${name}] cannot be extracted","messagePattern":"distribution type \\[(.+?)\\] for elasticsearch distribution \\[(.+?)\\] cannot be extracted","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java","lineNumber":199,"sourceCode":"     * freezes the distribution configuration and\n     * runs distribution finalizer logic.\n     */\n    public ElasticsearchDistribution maybeFreeze() {\n        if (frozen == false) {\n            finalizeValues();\n            frozen = true;\n        }\n        return this;\n    }\n\n    public String getFilepath() {\n        maybeFreeze();\n        return configuration.getSingleFile().toString();\n    }\n\n    public ConfigurableFileCollection getExtracted() {\n        if (getType().shouldExtract() == false) {\n            throw new UnsupportedOperationException(\n                \"distribution type [\" + getType().getName() + \"] for \" + \"elasticsearch distribution [\" + name + \"] cannot be extracted\"\n            );\n        }\n        return extracted;\n    }\n\n    @Override\n    public TaskDependency getBuildDependencies() {\n        if (skippingDockerDistributionBuild()) {\n            return task -> Collections.emptySet();\n        } else {\n            maybeFreeze();\n            return getType().shouldExtract() && (preferArchive.get() == false)\n                ? extracted.getBuildDependencies()\n                : configuration.getBuildDependencies();\n        }\n    }\n","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java#L181-L217","documentation":"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.","triggerScenarios":"Calling distribution.getExtracted() on a distribution whose getType().shouldExtract() is false — i.e. one configured as DOCKER, RPM, or DEB.","commonSituations":"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.","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."],"exampleFix":"// before\ndef files = distribution.getExtracted()  // throws for docker\n// after\ndef files = distribution.getType().shouldExtract() ? distribution.getExtracted() : distribution.configuration","handlingStrategy":"type-guard","validationCode":"if (!distribution.getType().shouldExtract()) {\n    throw new IllegalArgumentException(\"Distribution \" + distribution.getName() + \" type \" + distribution.getType() + \" is not extractable\");\n}","typeGuard":"static boolean isExtractable(ElasticsearchDistribution d) {\n    return d.getType().shouldExtract();\n}","tryCatchPattern":"try {\n    return distribution.getExtracted();\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"cannot be extracted\")) {\n        return distribution.configuration; // fallback for non-extractable types\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["gradle","distribution","validation","api-misuse"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}