Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/91981.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 91981
summary: Handle any exception thrown while generating source for an `IngestDocument`
area: Ingest Node
type: bug
issues: []
18 changes: 14 additions & 4 deletions server/src/main/java/org/elasticsearch/ingest/IngestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -945,17 +945,27 @@ private void innerExecute(
boolean ensureNoSelfReferences = ingestDocument.doNoSelfReferencesCheck();
indexRequest.source(ingestDocument.getSource(), indexRequest.getContentType(), ensureNoSelfReferences);
} catch (IllegalArgumentException ex) {
// An IllegalArgumentException can be thrown when an ingest
// processor creates a source map that is self-referencing.
// In that case, we catch and wrap the exception so we can
// include which pipeline failed.
// An IllegalArgumentException can be thrown when an ingest processor creates a source map that is self-referencing.
// In that case, we catch and wrap the exception, so we can include which pipeline failed.
handler.accept(
new IllegalArgumentException(
"Failed to generate the source document for ingest pipeline [" + pipeline.getId() + "]",
ex
)
);
return;
} catch (Exception ex) {
// If anything goes wrong here, we want to know, and cannot proceed with normal execution. For example,
// *rarely*, a ConcurrentModificationException could be thrown if a pipeline leaks a reference to a shared mutable
// collection, and another indexing thread modifies the shared reference while we're trying to ensure it has
// no self references.
handler.accept(
new RuntimeException(
"Failed to generate the source document for ingest pipeline [" + pipeline.getId() + "]",
ex
)
);
return;
}
Map<String, String> map;
if ((map = metadata.getDynamicTemplates()) != null) {
Expand Down