elastic/elasticsearch · error · IllegalArgumentException

No condition specified for ${missingOS}

Error message

No condition specified for ${missingOS}

What it means

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.

Source

Thrown at build-tools/src/main/java/org/elasticsearch/gradle/OS.java:72

            return this;
        }

        public Conditional<T> onMac(Supplier<T> supplier) {
            conditions.put(MAC, supplier);
            return this;
        }

        public Conditional<T> onUnix(Supplier<T> supplier) {
            conditions.put(MAC, supplier);
            conditions.put(LINUX, supplier);
            return this;
        }

        public T supply() {
            Set<OS> missingOS = EnumSet.allOf(OS.class);
            missingOS.removeAll(conditions.keySet());
            if (missingOS.isEmpty() == false) {
                throw new IllegalArgumentException("No condition specified for " + missingOS);
            }
            return conditions.get(OS.current()).get();
        }

    }

    public static <T> Conditional<T> conditional() {
        return new Conditional<>();
    }

    public static Conditional<String> conditionalString() {
        return conditional();
    }

}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Use onUnix(...).onWindows(...) as the idiomatic complete coverage (onUnix handles MAC+LINUX).
  2. If branches differ per OS, set all three: onWindows(...).onLinux(...).onMac(...).
  3. Audit any Conditional that throws by printing the missingOS set in the error — it names exactly which OS values lack suppliers.

Example fix

// before
String path = OS.<String>conditional()
  .onLinux(() -> linuxPath) // throws: MAC and WINDOWS missing
  .supply();
// after
String path = OS.<String>conditional()
  .onUnix(() -> unixPath)    // covers MAC + LINUX
  .onWindows(() -> winPath)  // covers WINDOWS
  .supply();
Defensive patterns

Strategy: validation

Validate before calling

// Ensure all three OS values are covered before supply()
OS.Conditional<T> c = OS.conditional();
// ... register suppliers ...
if (!c.isComplete()) throw new IllegalArgumentException("Conditional missing OS branches");
// (no public isComplete; the idiomatic guard is to always use onUnix+onWindows)

Prevention

When it happens

Trigger: 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().

Common situations: 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.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/1fb682615dfd7b39. Report an issue: GitHub.