{"record":{"id":"763eb701d18409dd","repo":"elastic/elasticsearch","slug":"platform-cannot-be-set-on-elasticsearch-distributi","errorCode":null,"errorMessage":"platform cannot be set on elasticsearch distribution [${name}] of type [integ_test_zip]","messagePattern":"platform cannot be set on elasticsearch distribution \\[(.+?)\\] of type \\[integ_test_zip\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java","lineNumber":232,"sourceCode":"                : configuration.getBuildDependencies();\n        }\n    }\n\n    private boolean skippingDockerDistributionBuild() {\n        return isDocker() && getFailIfUnavailable() == false && dockerAvailability.get() == false;\n    }\n\n    @Override\n    public Iterator<File> iterator() {\n        maybeFreeze();\n        return getType().shouldExtract() ? extracted.iterator() : configuration.iterator();\n    }\n\n    // internal, make this distribution's configuration unmodifiable\n    void finalizeValues() {\n        if (getType() == ElasticsearchDistributionTypes.INTEG_TEST_ZIP) {\n            if (platform.getOrNull() != null) {\n                throw new IllegalArgumentException(\n                    \"platform cannot be set on elasticsearch distribution [\" + name + \"] of type [integ_test_zip]\"\n                );\n            }\n            if (bundledJdk.getOrNull() != null) {\n                throw new IllegalArgumentException(\n                    \"bundledJdk cannot be set on elasticsearch distribution [\" + name + \"] of type [integ_test_zip]\"\n                );\n            }\n            return;\n        }\n\n        if (isDocker() == false && failIfUnavailable.get() == false) {\n            throw new IllegalArgumentException(\n                \"failIfUnavailable cannot be 'false' on elasticsearch distribution [\" + name + \"] of type [\" + getType() + \"]\"\n            );\n        }\n\n        if (getType() == ElasticsearchDistributionTypes.ARCHIVE) {","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java#L214-L250","documentation":"finalizeValues rejects setting platform on an INTEG_TEST_ZIP distribution: the integ-test zip is platform-independent, so pinning a platform is a configuration error. The check fires when the distribution is frozen (via maybeFreeze, triggered by getFilepath/getBuildDependencies/iterator).","triggerScenarios":"Calling setPlatform(...) on a distribution whose type is (or will be) INTEG_TEST_ZIP, then triggering finalization — directly or by reading a property that calls maybeFreeze.","commonSituations":"A build block unconditionally sets platform on every distribution including the integ-test zip; a refactor changed the type to integ_test_zip but left the platform line; a shared helper applies platform defaults to all distributions.","solutions":["Do not call setPlatform for integ_test_zip distributions.","Branch on type before applying platform: only set it for ARCHIVE.","Remove the platform line from the distribution configuration block that targets integ_test_zip."],"exampleFix":"// before\ndistribution.type = ElasticsearchDistributionTypes.INTEG_TEST_ZIP\ndistribution.platform = Platform.LINUX  // rejected on freeze\n// after\ndistribution.type = ElasticsearchDistributionTypes.INTEG_TEST_ZIP\n// no platform line — integ_test_zip is platform-independent","handlingStrategy":"validation","validationCode":"if (distribution.getType() == ElasticsearchDistributionTypes.INTEG_TEST_ZIP && distribution.getPlatform() != null) {\n    throw new IllegalArgumentException(\"platform must not be set on integ_test_zip\");\n}","typeGuard":"static boolean platformAllowed(ElasticsearchDistribution d) {\n    return d.getType() != ElasticsearchDistributionTypes.INTEG_TEST_ZIP;\n}","tryCatchPattern":null,"preventionTips":["Only set platform for ARCHIVE distributions.","Centralise distribution configuration so platform is applied conditionally on type.","Write a quick unit test asserting integ_test_zip rejects platform."],"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"}