diff --git a/core/src/main/java/org/elasticsearch/ingest/ConfigurationUtils.java b/core/src/main/java/org/elasticsearch/ingest/ConfigurationUtils.java index 88105420e14..8eaf44048c1 100644 --- a/core/src/main/java/org/elasticsearch/ingest/ConfigurationUtils.java +++ b/core/src/main/java/org/elasticsearch/ingest/ConfigurationUtils.java @@ -280,6 +280,7 @@ public final class ConfigurationUtils { public static Processor readProcessor(Map processorFactories, String type, Map config) throws Exception { + String tag = ConfigurationUtils.readOptionalStringProperty(null, null, config, TAG_KEY); Processor.Factory factory = processorFactories.get(type); if (factory != null) { boolean ignoreFailure = ConfigurationUtils.readBooleanProperty(null, null, config, "ignore_failure", false); @@ -287,7 +288,6 @@ public final class ConfigurationUtils { ConfigurationUtils.readOptionalList(null, null, config, Pipeline.ON_FAILURE_KEY); List onFailureProcessors = readProcessorConfigs(onFailureProcessorConfigs, processorFactories); - String tag = ConfigurationUtils.readOptionalStringProperty(null, null, config, TAG_KEY); if (onFailureProcessorConfigs != null && onFailureProcessors.isEmpty()) { throw newConfigurationException(type, tag, Pipeline.ON_FAILURE_KEY, @@ -309,6 +309,6 @@ public final class ConfigurationUtils { throw newConfigurationException(type, tag, null, e); } } - throw new ElasticsearchParseException("No processor type exists with name [" + type + "]"); + throw newConfigurationException(type, tag, null, "No processor type exists with name [" + type + "]"); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/ConfigurationUtilsTests.java b/core/src/test/java/org/elasticsearch/ingest/ConfigurationUtilsTests.java index f2d9aaa5170..eacc93a96fd 100644 --- a/core/src/test/java/org/elasticsearch/ingest/ConfigurationUtilsTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/ConfigurationUtilsTests.java @@ -31,6 +31,8 @@ import org.elasticsearch.test.ESTestCase; import org.junit.Before; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; import static org.mockito.Mockito.mock; @@ -105,12 +107,17 @@ public class ConfigurationUtilsTests extends ESTestCase { assertThat(result.get(0), sameInstance(processor)); assertThat(result.get(1), sameInstance(processor)); - config.add(Collections.singletonMap("unknown_processor", emptyConfig)); + Map unknownTaggedConfig = new HashMap<>(); + unknownTaggedConfig.put("tag", "my_unknown"); + config.add(Collections.singletonMap("unknown_processor", unknownTaggedConfig)); try { ConfigurationUtils.readProcessorConfigs(config, registry); fail("exception expected"); } catch (ElasticsearchParseException e) { assertThat(e.getMessage(), equalTo("No processor type exists with name [unknown_processor]")); + assertThat(e.getHeader("processor_tag"), equalTo(Collections.singletonList("my_unknown"))); + assertThat(e.getHeader("processor_type"), equalTo(Collections.singletonList("unknown_processor"))); + assertThat(e.getHeader("property_name"), is(nullValue())); } }