{"record":{"id":"76ec0e3a5a245554","repo":"elastic/elasticsearch","slug":"failed-to-parse-value-as-only-true-or-fals","errorCode":null,"errorMessage":"Failed to parse value [{}] as only [true] or [false] are allowed.","messagePattern":"Failed to parse value \\[(.+?)\\] as only \\[true\\] or \\[false\\] are allowed\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"libs/cli-terminal/src/main/java/org/elasticsearch/cli/terminal/Terminal.java","lineNumber":509,"sourceCode":"        }\n\n        @Override\n        public void errorPrintln(Verbosity verbosity, Throwable throwable) {\n            if (isPrintable(verbosity)) {\n                String json = EcsJsonUtils.formatJson(\"WARN\", \"stderr\", throwable.getMessage(), throwable);\n                delegate.errorPrintln(Verbosity.SILENT, json);\n            }\n        }\n    }\n\n    private static boolean parseBoolean(String value, boolean defaultValue) {\n        if (value == null || value.isBlank()) {\n            return defaultValue;\n        }\n        return switch (value) {\n            case \"true\" -> true;\n            case \"false\" -> false;\n            default -> throw new IllegalArgumentException(\"Failed to parse value [\" + value + \"] as only [true] or [false] are allowed.\");\n        };\n    }\n}\n","sourceCodeStart":491,"sourceCodeEnd":513,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/cli-terminal/src/main/java/org/elasticsearch/cli/terminal/Terminal.java#L491-L513","documentation":"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.","triggerScenarios":"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.","commonSituations":"Operators assume 1/0 works. Tools that emit `True`/`False` capitalized. Bash boolean idioms (`$(( 1 ))`) leaking into the value.","solutions":["Set the value to exactly `true` or `false` (lowercase).","Identify which env var is being parsed by checking the Terminal subsystem's documented flags.","Normalize values in your shell: `export ES_QUIET=$([ \"$QUIET\" = 1 ] && echo true || echo false)`."],"exampleFix":"# before\nexport ES_QUIET=1\n# after\nexport ES_QUIET=true","handlingStrategy":"validation","validationCode":"static boolean parseTerminalBool(String v, boolean def) {\n    if (v == null || v.isBlank()) return def;\n    if (v.equals(\"true\")) return true;\n    if (v.equals(\"false\")) return false;\n    throw new IllegalArgumentException(\"Expected 'true' or 'false', got: \" + v);\n}","typeGuard":"static boolean isCanonicalBoolean(String v) {\n    return \"true\".equals(v) || \"false\".equals(v);\n}","tryCatchPattern":"try {\n    Terminal terminal = Terminal.fromEnv(...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"only [true] or [false]\")) {\n        // normalize the offending env var to true/false and retry\n    } else throw e;\n}","preventionTips":["Use only lowercase `true`/`false` for terminal-related env vars.","Normalize 1/0 or yes/no upstream with a small shell helper.","Document the exact accepted values wherever the env vars are configured."],"tags":["cli","terminal","boolean","parsing","configuration"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}