{"record":{"id":"b15c14e72c265286","repo":"elastic/elasticsearch","slug":"unable-to-parse-date","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/DateIndexNameProcessor.java","lineNumber":85,"sourceCode":"        String date = null;\n        if (obj != null) {\n            // Not use Objects.toString(...) here, because null gets changed to \"null\" which may confuse some date parsers\n            date = obj.toString();\n        }\n\n        ZonedDateTime dateTime = null;\n        Exception lastException = null;\n        for (Function<String, ZonedDateTime> dateParser : dateFormats) {\n            try {\n                dateTime = dateParser.apply(date);\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 [\" + date + \"]\", lastException);\n        }\n        String indexNamePrefix = ingestDocument.renderTemplate(indexNamePrefixTemplate);\n        String indexNameFormat = ingestDocument.renderTemplate(indexNameFormatTemplate);\n        String dateRounding = ingestDocument.renderTemplate(dateRoundingTemplate);\n\n        DateFormatter formatter = DateFormatter.forPattern(indexNameFormat);\n        // use UTC instead of Z is string representation of UTC, so behaviour is the same between 6.x and 7\n        String zone = timezone.equals(ZoneOffset.UTC) ? \"UTC\" : timezone.getId();\n        StringBuilder builder = new StringBuilder().append('<')\n            .append(indexNamePrefix)\n            .append('{')\n            .append(formatter.format(dateTime))\n            .append(\"||/\")\n            .append(dateRounding)\n            .append('{')\n            .append(indexNameFormat)\n            .append('|')\n            .append(zone)","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateIndexNameProcessor.java#L67-L103","documentation":"Thrown by DateIndexNameProcessor after it has tried every configured date_formats parser against the input value and none succeeded. The exception chains all suppressed parse errors via ExceptionsHelper.useOrSuppress. Unlike DateProcessor, this processor uses the index name rounding/template machinery; the parse failure happens before any of that, on the raw date string.","triggerScenarios":"A date_index_name processor whose 'date_formats' list (default 'yyyy-MM-dd\\'T\\'HH:mm:ss.SSSXX') does not match any format present in the input field value. All configured Joda/Java DateTimeFormatter patterns fail and dateTime remains null.","commonSituations":"Epoch timestamps fed without the 'ISO8601' or custom epoch format; locale-specific date strings; mismatches between the producer's date format and the pipeline's date_formats list; switching from Joda to java-time syntax during upgrades (some format tokens changed).","solutions":["Add the matching format string to the processor's 'date_formats' array (use 'ISO8601' for standard, 'UNIX'/'UNIX_MS' for epoch, or an explicit java-time pattern).","Inspect the suppressed exceptions on the thrown IllegalArgumentException to see why each parser rejected the value.","Normalize the date with a script/gsub processor before date_index_name if the producer cannot be changed."],"exampleFix":"// before - input field value is epoch seconds 1700000000, default format fails\n{\"date_index_name\": {\"field\": \"ts\", \"index_name_prefix\": \"logs-\", \"date_rounding\": \"d\"}}\n// after - declare epoch format\n{\"date_index_name\": {\"field\": \"ts\", \"index_name_prefix\": \"logs-\", \"date_rounding\": \"d\", \"date_formats\": [\"UNIX\"]}}","handlingStrategy":"try-catch","validationCode":"// In a script processor, attempt a known format and fall back to others before date_index_name:\n{\"script\": {\"source\": \"try { ZonedDateTime.parse(ctx.ts); } catch (Exception e) { /* leave for on_failure */ throw e; }\"}}","typeGuard":null,"tryCatchPattern":"// Pipeline on_failure to retry with a different format or quarantine:\n{\"on_failure\": [{\"date_index_name\": {\"field\": \"ts\", \"date_formats\": [\"UNIX\"], \"index_name_prefix\": \"logs-\", \"date_rounding\": \"d\"}}]}","preventionTips":["Always include 'ISO8601', 'UNIX', and 'UNIX_MS' alongside any custom patterns in date_formats.","Audit suppressed exceptions to confirm each declared pattern is valid.","Pre-normalize epoch/ISO mismatches at the producer."],"tags":["ingest","date-processor","date-parsing","date-index-name"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}