elastic/elasticsearch · error · IllegalArgumentException

unable to parse date [{}]

Error message

unable to parse date [{}]

What it means

Thrown by DateProcessor.execute when extracting the per-document timezone or locale fails (e.g. the rendered timezone/locale templates resolve to a value ZoneId.of or Locale lookup cannot handle). This is the wrapper for failures during getTimezone/getLocale, distinct from the all-parsers-exhausted error at line 130. The original exception is attached as cause.

Source

Thrown at modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateProcessor.java:114

    @Override
    public IngestDocument execute(IngestDocument document) {
        Object obj = document.getFieldValue(field, Object.class);
        String value = null;
        if (obj != null) {
            // Don't use Objects.toString(...) here, because null gets changed to "null" which may confuse some date parsers
            value = obj.toString();
        }

        // run (potential) mustache application just a single time for this document in order to
        // extract the timezone and locale to use for date parsing
        final ZoneId documentTimezone;
        final Locale documentLocale;
        try {
            documentTimezone = getTimezone(document);
            documentLocale = getLocale(document);
        } catch (Exception e) {
            throw new IllegalArgumentException("unable to parse date [" + value + "]", e);
        }

        ZonedDateTime dateTime = null;
        Exception lastException = null;
        for (BiFunction<ZoneId, Locale, Function<String, ZonedDateTime>> dateParser : dateParsers) {
            try {
                dateTime = dateParser.apply(documentTimezone, documentLocale).apply(value);
                break;
            } catch (Exception e) {
                // try the next parser and keep track of the exceptions
                lastException = ExceptionsHelper.useOrSuppress(lastException, e);
            }
        }

        if (dateTime == null) {
            throw new IllegalArgumentException("unable to parse date [" + value + "]", lastException);
        }

View on GitHub (pinned to db6a809a66)

Solutions

  1. Inspect the rendered timezone/locale value in the failing document (the cause exception names the specific failure).
  2. Validate timezone strings against java.time.ZoneId.getAvailableZoneIds() at the producer, or constrain the document field to IANA IDs.
  3. Fall back to a fixed timezone/locale by removing the template and using a literal value.
  4. Add an on_failure handler to quarantine documents with malformed zone/locale fields.

Example fix

// before - templated timezone from field that sometimes holds 'UTC+02'
{"date": {"field": "ts", "formats": ["ISO8601"], "timezone": "{{{tz}}}"}}
// after - use valid IANA zone IDs in source data, or fixed zone
{"date": {"field": "ts", "formats": ["ISO8601"], "timezone": "UTC"}}
Defensive patterns

Strategy: validation

Validate before calling

// Validate the per-document timezone/locale template values via a script processor before date:
{"script": {"source": "if (ctx.tz != null && ZoneId.of(ctx.tz) == null) { throw new Exception('bad zone'); }"}}

Type guard

// painless
boolean is_valid_zone(String z) { try { ZoneId.of(z); return true; } catch (Exception e) { return false; } }

Try / catch

{"on_failure": [{"index": {"index": "ingest-dlq"}}]}

Prevention

When it happens

Trigger: A date processor configured with templated 'timezone' or 'locale' values that, after mustache rendering, produce an invalid ZoneId string (e.g. 'PST8PDTXX', 'UTC+02') or an invalid locale string. The exception is thrown before any date format parser is attempted.

Common situations: Templated timezones sourced from document fields that occasionally carry bad values; timezone strings with malformed offsets; non-IANA zone IDs like 'EST' that some JVMs reject; locale fields containing underscores or empty strings.

Understand the failure class

Related errors


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