Skip to content

Commit 5d28df2

Browse files
authored
EnrichProcessorFactory should not throw NPE if missing metadata (elastic#55977) (elastic#56843)
In some cases the Enrich processor factory may be called before it is ready to create processors. While these calls are usually made in error, the response from the Enrich processor is an NPE which is almost always an unhelpful error when debugging an issue.
1 parent e6d545e commit 5d28df2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichProcessorFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ final class EnrichProcessorFactory implements Processor.Factory, Consumer<Cluste
3838
public Processor create(Map<String, Processor.Factory> processorFactories, String tag, Map<String, Object> config) throws Exception {
3939
String policyName = ConfigurationUtils.readStringProperty(TYPE, tag, config, "policy_name");
4040
String policyAlias = EnrichPolicy.getBaseName(policyName);
41+
if (metadata == null) {
42+
throw new IllegalStateException("enrich processor factory has not yet been initialized with cluster state");
43+
}
4144
IndexAbstraction indexAbstraction = metadata.getIndicesLookup().get(policyAlias);
4245
if (indexAbstraction == null) {
4346
throw new IllegalArgumentException("no enrich index exists for policy with name [" + policyName + "]");

0 commit comments

Comments
 (0)