elastic/elasticsearch · error · IllegalArgumentException

invalid value [ ] must be one of [true,false,limited]

Error message

invalid value [{}] must be one of [true,false,limited]

What it means

CompilerSettings.RegexEnabled.parse accepts exactly three lowercase string values for 'script.painless.regex.enabled': 'true', 'false', 'limited'. Unlike enum valueOf (which needs uppercase), this parser does a manual string compare and throws IllegalArgumentException listing the allowed set for any other input, including 'TRUE', 'False', 'on', 'off', 'yes', 'no', or typos.

Solutions

  1. Use one of the exact lowercase literals: 'true', 'false', or 'limited'.
  2. In YAML, quote the value to prevent implicit type coercion: script.painless.regex.enabled: "limited".
  3. If applying via API, ensure the JSON value is a string of one of the three allowed literals.

Example fix

// before
script.painless.regex.enabled: TRUE
// after
script.painless.regex.enabled: "limited"
Defensive patterns

Strategy: validation

Validate before calling

function validateRegexEnabled(v) {
  const allowed = ['true','false','limited'];
  if (!allowed.includes(String(v).toLowerCase()) || String(v) !== String(v).toLowerCase()) {
    throw new Error(`script.painless.regex.enabled must be one of ${allowed.join(',')} (lowercase)`);
  }
  return v;
}

Prevention

When it happens

Trigger: Setting script.painless.regex.enabled to anything other than the literal strings 'true', 'false', or 'limited' — e.g. uppercase 'TRUE', 'enabled', '1', 'on', or a typo like 'limitted'.

Common situations: Porting a setting from another tool that accepts 'on'/'off' or uppercase booleans. YAML auto-conversion turning the value into a boolean type rather than the expected lowercase string. Copy-paste typos.

Related errors


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

Appendix: source

Thrown at modules/lang-painless/src/main/java/org/elasticsearch/painless/CompilerSettings.java:274

        final String value;

        RegexEnabled(String value) {
            this.value = value;
        }

        /**
         * Parse string value, necessary because `valueOf` would require strings to be upper case.
         */
        public static RegexEnabled parse(String value) {
            if (TRUE.value.equals(value)) {
                return TRUE;
            } else if (FALSE.value.equals(value)) {
                return FALSE;
            } else if (LIMITED.value.equals(value)) {
                return LIMITED;
            }
            throw new IllegalArgumentException(
                "invalid value [" + value + "] must be one of [" + TRUE.value + "," + FALSE.value + "," + LIMITED.value + "]"
            );
        }
    }
}

View on GitHub (pinned to db6a809a66)