elastic/elasticsearch · error · IllegalArgumentException

Failed to parse value [{}] as only [true] or [false] are all

Error message

Failed to parse value [{}] as only [true] or [false] are allowed.

What it means

Thrown by Terminal.parseBoolean when a string intended to represent a boolean verbosity/quiet flag is neither `true` nor `false` (case-sensitive exact match). The Terminal class uses this internal helper to interpret environment-driven terminal configuration (e.g. ES_*_QUIET, ES_*_VERBOSE style flags). Any other value — `yes`, `1`, `on`, `TRUE` — is rejected. The error is an IllegalArgumentException, surfaced to the user as a startup failure.

Source

Thrown at libs/cli-terminal/src/main/java/org/elasticsearch/cli/terminal/Terminal.java:509

        }

        @Override
        public void errorPrintln(Verbosity verbosity, Throwable throwable) {
            if (isPrintable(verbosity)) {
                String json = EcsJsonUtils.formatJson("WARN", "stderr", throwable.getMessage(), throwable);
                delegate.errorPrintln(Verbosity.SILENT, json);
            }
        }
    }

    private static boolean parseBoolean(String value, boolean defaultValue) {
        if (value == null || value.isBlank()) {
            return defaultValue;
        }
        return switch (value) {
            case "true" -> true;
            case "false" -> false;
            default -> throw new IllegalArgumentException("Failed to parse value [" + value + "] as only [true] or [false] are allowed.");
        };
    }
}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Set the value to exactly `true` or `false` (lowercase).
  2. Identify which env var is being parsed by checking the Terminal subsystem's documented flags.
  3. Normalize values in your shell: `export ES_QUIET=$([ "$QUIET" = 1 ] && echo true || echo false)`.

Example fix

# before
export ES_QUIET=1
# after
export ES_QUIET=true
Defensive patterns

Strategy: validation

Validate before calling

static boolean parseTerminalBool(String v, boolean def) {
    if (v == null || v.isBlank()) return def;
    if (v.equals("true")) return true;
    if (v.equals("false")) return false;
    throw new IllegalArgumentException("Expected 'true' or 'false', got: " + v);
}

Type guard

static boolean isCanonicalBoolean(String v) {
    return "true".equals(v) || "false".equals(v);
}

Try / catch

try {
    Terminal terminal = Terminal.fromEnv(...);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("only [true] or [false]")) {
        // normalize the offending env var to true/false and retry
    } else throw e;
}

Prevention

When it happens

Trigger: Setting a terminal-related env var to `yes`, `1`, `on`, or any case variant other than the exact strings `true`/`false`. Copying shell snippets that use `enable`/`disable` style values.

Common situations: Operators assume 1/0 works. Tools that emit `True`/`False` capitalized. Bash boolean idioms (`$(( 1 ))`) leaking into the value.

Understand the failure class

Related errors


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