{"record":{"id":"1fb682615dfd7b39","repo":"elastic/elasticsearch","slug":"no-condition-specified-for-missingos","errorCode":null,"errorMessage":"No condition specified for ${missingOS}","messagePattern":"No condition specified for (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/OS.java","lineNumber":72,"sourceCode":"            return this;\n        }\n\n        public Conditional<T> onMac(Supplier<T> supplier) {\n            conditions.put(MAC, supplier);\n            return this;\n        }\n\n        public Conditional<T> onUnix(Supplier<T> supplier) {\n            conditions.put(MAC, supplier);\n            conditions.put(LINUX, supplier);\n            return this;\n        }\n\n        public T supply() {\n            Set<OS> missingOS = EnumSet.allOf(OS.class);\n            missingOS.removeAll(conditions.keySet());\n            if (missingOS.isEmpty() == false) {\n                throw new IllegalArgumentException(\"No condition specified for \" + missingOS);\n            }\n            return conditions.get(OS.current()).get();\n        }\n\n    }\n\n    public static <T> Conditional<T> conditional() {\n        return new Conditional<>();\n    }\n\n    public static Conditional<String> conditionalString() {\n        return conditional();\n    }\n\n}\n","sourceCodeStart":54,"sourceCodeEnd":88,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/OS.java#L54-L88","documentation":"OS.Conditional.supply() throws IllegalArgumentException when not all three OS enum values (WINDOWS, MAC, LINUX) have a registered supplier. The Conditional is a total-function builder: it must cover every OS because supply() will dispatch to OS.current() at runtime. The helper onUnix() registers both MAC and LINUX in one call, so the common pattern onUnix(...).onWindows(...) satisfies the requirement.","triggerScenarios":"Building a Conditional with only onLinux(...) (missing MAC and WINDOWS), or only onMac(...) (missing LINUX and WINDOWS), or any combination that leaves at least one OS uncovered, then calling .supply().","commonSituations":"Adding a Linux-only branch and forgetting MAC is a separate enum value; not realizing onUnix() covers both MAC and LINUX while onLinux() covers only LINUX; assuming an uncovered OS will never run so the branch is unreachable.","solutions":["Use onUnix(...).onWindows(...) as the idiomatic complete coverage (onUnix handles MAC+LINUX).","If branches differ per OS, set all three: onWindows(...).onLinux(...).onMac(...).","Audit any Conditional that throws by printing the missingOS set in the error — it names exactly which OS values lack suppliers."],"exampleFix":"// before\nString path = OS.<String>conditional()\n  .onLinux(() -> linuxPath) // throws: MAC and WINDOWS missing\n  .supply();\n// after\nString path = OS.<String>conditional()\n  .onUnix(() -> unixPath)    // covers MAC + LINUX\n  .onWindows(() -> winPath)  // covers WINDOWS\n  .supply();","handlingStrategy":"validation","validationCode":"// Ensure all three OS values are covered before supply()\nOS.Conditional<T> c = OS.conditional();\n// ... register suppliers ...\nif (!c.isComplete()) throw new IllegalArgumentException(\"Conditional missing OS branches\");\n// (no public isComplete; the idiomatic guard is to always use onUnix+onWindows)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to the onUnix(...).onWindows(...) idiom for full coverage.","When specifying per-OS branches, always set all three: onWindows, onLinux, onMac.","Remember onLinux covers LINUX only; onUnix covers MAC + LINUX."],"tags":["gradle","build-tools","os-detection","configuration-validation"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}