{"record":{"id":"1ac6d9b7c4d01fad","repo":"elastic/elasticsearch","slug":"error-parsing-document-in-field","errorCode":null,"errorMessage":"Error parsing document in field [{}]","messagePattern":"Error parsing document in field \\[(.+?)\\]","errorType":"exception","errorClass":"ElasticsearchParseException","httpStatus":null,"severity":"error","filePath":"modules/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/AttachmentProcessor.java","lineNumber":232,"sourceCode":"            indexedCharsValue = ingestDocument.getFieldValue(indexedCharsField, Integer.class, true);\n            if (indexedCharsValue == null) {\n                // If the field does not exist we fall back to the global limit\n                indexedCharsValue = this.indexedChars;\n            }\n        }\n\n        Metadata metadata = new Metadata();\n        if (resourceNameInput != null) {\n            metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY, resourceNameInput);\n        }\n        String parsedContent = \"\";\n        try {\n            parsedContent = TikaImpl.parse(input, metadata, indexedCharsValue);\n        } catch (ZeroByteFileException e) {\n            // tika 1.17 throws an exception when the InputStream has 0 bytes.\n            // previously, it did not mind. This is here to preserve that behavior.\n        } catch (Exception e) {\n            throw new ElasticsearchParseException(\"Error parsing document in field [{}]\", e, field);\n        }\n\n        if (properties.contains(Property.CONTENT) && Strings.hasLength(parsedContent)) {\n            // somehow tika seems to append a newline at the end automatically, lets remove that again\n            additionalFields.put(Property.CONTENT.toLowerCase(), parsedContent.trim());\n        }\n\n        if (properties.contains(Property.LANGUAGE) && Strings.hasLength(parsedContent)) {\n            // TODO: stop using LanguageIdentifier...\n            LanguageIdentifier identifier = new LanguageIdentifier(parsedContent);\n            String language = identifier.getLanguage();\n            additionalFields.put(Property.LANGUAGE.toLowerCase(), language);\n        }\n\n        addAdditionalField(additionalFields, Property.DATE, metadata.get(TikaCoreProperties.CREATED));\n        addAdditionalField(additionalFields, Property.TITLE, metadata.get(TikaCoreProperties.TITLE));\n        // These two were supposedly removed in tika 2, but some parsers seem to still generate them:\n        addAdditionalField(additionalFields, Property.AUTHOR, metadata.get(\"Author\"));","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/AttachmentProcessor.java#L214-L250","documentation":"ElasticsearchParseException wrapping any non-ZeroByteFileException thrown by Tika while parsing the attachment bytes. The field name is passed as the argument so the error points at the offending source field. This is the generic catch-all for corrupt, truncated, password-protected (other than public-key), or unsupported-format documents.","triggerScenarios":"TikaImpl.parse throws a TikaException/IOException for a malformed, truncated, or unsupported file; the catch(Exception) in execute re-wraps it. Zero-byte files are intentionally swallowed separately.","commonSituations":"Corrupt PDFs/Office docs; truncated uploads; password-protected Office files; formats Tika cannot handle; encoding issues in transit.","solutions":["Inspect the chained cause for the Tika-specific failure reason","Validate/repair the source document out-of-band before ingest","Add on_failure handling in the pipeline to route failed docs to a dead-letter index"],"exampleFix":"// before\nPUT _ingest/pipeline/attach\n{\"processors\":[{\"attachment\":{\"field\":\"data\"}}]}\n// after: route parse failures instead of failing the bulk request\n{\"processors\":[{\"attachment\":{\"field\":\"data\",\"on_failure\":[{\"index\":{\"index\":\"attach-failures\",\"pipeline\":\"_none\"}}]}}]}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { ingest(attachmentPipeline, doc); }\ncatch (ElasticsearchParseException e) {\n    Throwable cause = e.getCause(); // Tika-specific\n    routeToFailureIndex(doc, cause);\n}","preventionTips":["Always configure on_failure on attachment pipelines to isolate bad documents","Pre-validate file integrity (e.g. magic bytes, size) before ingest","Log the Tika cause to classify recurring failure modes"],"tags":["ingest","attachment","tika","parse-error","on-failure"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}