Skip to content

Commit a9003c9

Browse files
authored
[8.x] Fix NPE in EnrichLookupService on mixed clusters with <8.14 versions (#116583) (#116607)
* Fix NPE in EnrichLookupService on mixed clusters with <8.14 versions (#116583) Fixes #116529 Fixes #116544 * Changed switch type for 8.x
1 parent 1c299fd commit a9003c9

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

docs/changelog/116583.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pr: 116583
2+
summary: Fix NPE in `EnrichLookupService` on mixed clusters with <8.14 versions
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 116529
7+
- 116544

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.elasticsearch.compute.operator.lookup.MergePositionsOperator;
4646
import org.elasticsearch.compute.operator.lookup.QueryList;
4747
import org.elasticsearch.core.AbstractRefCounted;
48+
import org.elasticsearch.core.Nullable;
4849
import org.elasticsearch.core.RefCounted;
4950
import org.elasticsearch.core.Releasable;
5051
import org.elasticsearch.core.Releasables;
@@ -182,6 +183,9 @@ protected static QueryList termQueryList(
182183
Block block,
183184
DataType inputDataType
184185
) {
186+
if (inputDataType == null) {
187+
return QueryList.rawTermQueryList(field, searchExecutionContext, block);
188+
}
185189
return switch (inputDataType) {
186190
case IP -> QueryList.ipTermQueryList(field, searchExecutionContext, (BytesRefBlock) block);
187191
case DATETIME -> QueryList.dateTermQueryList(field, searchExecutionContext, (LongBlock) block);
@@ -459,6 +463,10 @@ abstract static class Request {
459463
abstract static class TransportRequest extends org.elasticsearch.transport.TransportRequest implements IndicesRequest {
460464
final String sessionId;
461465
final ShardId shardId;
466+
/**
467+
* For mixed clusters with nodes &lt;8.14, this will be null.
468+
*/
469+
@Nullable
462470
final DataType inputDataType;
463471
final Page inputPage;
464472
final List<NamedExpression> extractFields;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ static TransportRequest readFrom(StreamInput in, BlockFactory blockFactory) thro
127127
TaskId parentTaskId = TaskId.readFromStream(in);
128128
String sessionId = in.readString();
129129
ShardId shardId = new ShardId(in);
130-
DataType inputDataType = DataType.fromTypeName(
131-
(in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) ? in.readString() : "unknown"
132-
);
130+
DataType inputDataType = (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0))
131+
? DataType.fromTypeName(in.readString())
132+
: null;
133133
String matchType = in.readString();
134134
String matchField = in.readString();
135135
Page inputPage;

0 commit comments

Comments
 (0)