{"record":{"id":"300fd5c4289373c8","repo":"elastic/elasticsearch","slug":"failifunavailable-cannot-be-false-on-elasticsear","errorCode":null,"errorMessage":"failIfUnavailable cannot be 'false' on elasticsearch distribution [${name}] of type [${type}]","messagePattern":"failIfUnavailable cannot be 'false' 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":245,"sourceCode":"\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) {\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(","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java#L227-L263","documentation":"failIfUnavailable=false is only meaningful for docker distributions (where it allows a build to proceed when docker is absent). For any non-docker type, finalizeValues treats turning it off as a configuration error and throws, because non-docker distributions have no availability check to skip.","triggerScenarios":"Calling setFailIfUnavailable(false) on a distribution whose type is ARCHIVE, INTEG_TEST_ZIP, RPM, or DEB, then freezing it. The check is `isDocker() == false && failIfUnavailable.get() == false`.","commonSituations":"A shared helper sets failIfUnavailable=false on all distributions to be permissive, not realising it is docker-specific; a copy-paste from a docker-only block; a refactor changed the type away from docker.","solutions":["Only set failIfUnavailable=false for DOCKER distributions.","Leave it at its default (true) for non-docker types.","Branch on isDocker() before applying the flag."],"exampleFix":"// before\ndistribution.type = ElasticsearchDistributionTypes.ARCHIVE\ndistribution.failIfUnavailable = false\n// after\ndistribution.type = ElasticsearchDistributionTypes.ARCHIVE\n// leave failIfUnavailable at its default (true)","handlingStrategy":"validation","validationCode":"if (!distribution.isDocker() && !distribution.getFailIfUnavailable()) {\n    throw new IllegalArgumentException(\"failIfUnavailable=false is only valid for docker distributions\");\n}","typeGuard":"static boolean failIfUnavailableAllowedFalse(ElasticsearchDistribution d) {\n    return d.isDocker();\n}","tryCatchPattern":null,"preventionTips":["Only set failIfUnavailable=false on DOCKER distributions.","Branch on isDocker() before applying the flag.","Leave non-docker distributions at the default (true)."],"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"}