{"record":{"id":"d4eb5de8b29b302c","repo":"elastic/elasticsearch","slug":"platform-cannot-be-set-on-elasticsearch-distributi-d4eb5d","errorCode":null,"errorMessage":"platform cannot be set on elasticsearch distribution [${name}] of type [${type}]","messagePattern":"platform cannot be set on elasticsearch distribution \\[(.+?)\\] of type \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java","lineNumber":257,"sourceCode":"                );\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) {\n            // defaults for archive, set here instead of via convention so integ-test-zip can verify they are not set\n            if (platform.isPresent() == false) {\n                platform.set(CURRENT_PLATFORM);\n            }\n        } else { // rpm, deb or docker\n            if (platform.isPresent()) {\n                throw new IllegalArgumentException(\n                    \"platform cannot be set on elasticsearch distribution [\" + name + \"] of type [\" + getType() + \"]\"\n                );\n            }\n            if (isDocker()) {\n                if (bundledJdk.isPresent()) {\n                    throw new IllegalArgumentException(\n                        \"bundledJdk cannot be set on elasticsearch distribution [\" + name + \"] of type \" + \"[docker]\"\n                    );\n                }\n            }\n        }\n\n        if (bundledJdk.isPresent() == false) {\n            bundledJdk.set(true);\n        }\n\n        version.finalizeValue();\n        platform.finalizeValue();","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java#L239-L275","documentation":"Thrown by ElasticsearchDistribution.finalizeValues() when a distribution whose type is rpm, deb, or docker has its `platform` property explicitly set. These packaging formats are inherently platform-bound (deb/rpm are Linux-only, docker is multi-arch via image tags), so an explicit platform is meaningless and would mislead the resolver. The check guards the configuration-time invariant before the distribution is frozen.","triggerScenarios":"Calling setPlatform(Platform.X) on an ElasticsearchDistribution whose getType() returns RPM, DEB, or DOCKER, then letting Gradle finalize the distribution's values (finalizeValues() runs during task graph configuration). Note ARCHIVE-type distributions are the only ones that accept (and auto-default) platform.","commonSituations":"Copy-pasting archive-style config (`dist.platform = ...`) into a docker/rpm/deb distribution block; migrating an archive distribution to docker without dropping the platform line; assuming platform is required for all distribution types because the ARCHIVE path auto-sets it.","solutions":["Remove the setPlatform(...) / platform = ... call from the rpm/deb/docker distribution configuration.","If you need a specific OS image for docker, select it via the version/tag or a different distribution type rather than platform.","Keep platform configuration only on ARCHIVE-type distributions, where it is meaningful and defaults to CURRENT_PLATFORM."],"exampleFix":"// before\ndistributions {\n  docker {\n    platform = ElasticsearchDistribution.Platform.LINUX // throws at finalizeValues\n  }\n}\n// after\ndistributions {\n  docker {\n    // platform omitted; docker image arch is selected via version/tag\n  }\n}","handlingStrategy":"validation","validationCode":"// Before finalizing, check the type/platform compatibility\nElasticsearchDistribution dist = ...;\nif (dist.getType() != ElasticsearchDistributionTypes.ARCHIVE) {\n    assert dist.getPlatform() == null : \"platform must not be set on non-ARCHIVE distribution \" + dist.getName();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call setPlatform on ARCHIVE-type distributions; rpm/deb/docker are platform-bound by their format.","Centralize distribution creation in a helper that refuses platform for non-archive types.","Review distribution config diffs for stray platform lines when changing the distribution type."],"tags":["gradle","build-tools","distribution","configuration-validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}