Browse Source

Fix pipeline id not present in ingest metadata inside on_failure block (#89632)

This commit fixes an issue where inside of an `on_failure` block the
`_ingest.on_failure_pipeline` metadata was not being propagated. The
root cause seems to be an off-by-one error where we were checking for at
least two pipelines, when we should be checking for only a minimum of a
single pipeline that has been executed before adding the metadata.
Lee Hinman 3 years ago
parent
commit
6161447659

+ 5 - 0
docs/changelog/89632.yaml

@@ -0,0 +1,5 @@
+pr: 89632
+summary: Fix pipeline id not present in ingest metadata inside `on_failure` block
+area: Ingest Node
+type: bug
+issues: []

+ 1 - 1
server/src/main/java/org/elasticsearch/ingest/CompoundProcessor.java

@@ -327,7 +327,7 @@ public class CompoundProcessor implements Processor {
         }
         if (document != null) {
             List<String> pipelineStack = document.getPipelineStack();
-            if (pipelineStack.size() > 1) {
+            if (pipelineStack.isEmpty() == false) {
                 exception.addHeader("pipeline_origin", pipelineStack);
             }
         }

+ 1 - 0
server/src/test/java/org/elasticsearch/action/ingest/SimulateExecutionServiceTests.java

@@ -181,6 +181,7 @@ public class SimulateExecutionServiceTests extends ESTestCase {
         metadata.put(CompoundProcessor.ON_FAILURE_PROCESSOR_TYPE_FIELD, "mock");
         metadata.put(CompoundProcessor.ON_FAILURE_PROCESSOR_TAG_FIELD, "processor_0");
         metadata.put(CompoundProcessor.ON_FAILURE_MESSAGE_FIELD, "processor failed");
+        metadata.put(CompoundProcessor.ON_FAILURE_PIPELINE_FIELD, "_id");
         assertVerboseResult(
             simulateDocumentVerboseResult.getProcessorResults().get(1),
             pipeline.getId(),