{"record":{"id":"5c6e2c6f21727574","repo":"elastic/elasticsearch","slug":"unable-to-parse-date-5c6e2c","errorCode":null,"errorMessage":"unable to parse date [{}]","messagePattern":"unable to parse date \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateProcessor.java","lineNumber":114,"sourceCode":"\n    @Override\n    public IngestDocument execute(IngestDocument document) {\n        Object obj = document.getFieldValue(field, Object.class);\n        String value = null;\n        if (obj != null) {\n            // Don't use Objects.toString(...) here, because null gets changed to \"null\" which may confuse some date parsers\n            value = obj.toString();\n        }\n\n        // run (potential) mustache application just a single time for this document in order to\n        // extract the timezone and locale to use for date parsing\n        final ZoneId documentTimezone;\n        final Locale documentLocale;\n        try {\n            documentTimezone = getTimezone(document);\n            documentLocale = getLocale(document);\n        } catch (Exception e) {\n            throw new IllegalArgumentException(\"unable to parse date [\" + value + \"]\", e);\n        }\n\n        ZonedDateTime dateTime = null;\n        Exception lastException = null;\n        for (BiFunction<ZoneId, Locale, Function<String, ZonedDateTime>> dateParser : dateParsers) {\n            try {\n                dateTime = dateParser.apply(documentTimezone, documentLocale).apply(value);\n                break;\n            } catch (Exception e) {\n                // try the next parser and keep track of the exceptions\n                lastException = ExceptionsHelper.useOrSuppress(lastException, e);\n            }\n        }\n\n        if (dateTime == null) {\n            throw new IllegalArgumentException(\"unable to parse date [\" + value + \"]\", lastException);\n        }\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateProcessor.java#L96-L132","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the rendered timezone/locale value in the failing document (the cause exception names the specific failure).","Validate timezone strings against java.time.ZoneId.getAvailableZoneIds() at the producer, or constrain the document field to IANA IDs.","Fall back to a fixed timezone/locale by removing the template and using a literal value.","Add an on_failure handler to quarantine documents with malformed zone/locale fields."],"exampleFix":"// before - templated timezone from field that sometimes holds 'UTC+02'\n{\"date\": {\"field\": \"ts\", \"formats\": [\"ISO8601\"], \"timezone\": \"{{{tz}}}\"}}\n// after - use valid IANA zone IDs in source data, or fixed zone\n{\"date\": {\"field\": \"ts\", \"formats\": [\"ISO8601\"], \"timezone\": \"UTC\"}}","handlingStrategy":"validation","validationCode":"// Validate the per-document timezone/locale template values via a script processor before date:\n{\"script\": {\"source\": \"if (ctx.tz != null && ZoneId.of(ctx.tz) == null) { throw new Exception('bad zone'); }\"}}","typeGuard":"// painless\nboolean is_valid_zone(String z) { try { ZoneId.of(z); return true; } catch (Exception e) { return false; } }","tryCatchPattern":"{\"on_failure\": [{\"index\": {\"index\": \"ingest-dlq\"}}]}","preventionTips":["Constrain document timezone fields to IANA zone IDs at the producer.","Use a fixed timezone/locale when per-document variation is not required.","Validate timezone strings against java.time.ZoneId.getAvailableZoneIds() upstream."],"tags":["ingest","date-processor","timezone","locale"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}