Skip to content

Commit c2d0793

Browse files
committed
do not let ShardBulkInferenceActionFilter unwrap / rewrap ESExceptions
1 parent 8baba58 commit c2d0793

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,14 @@ public void onFailure(Exception exc) {
290290
request.field
291291
);
292292
} else {
293-
failure = new ElasticsearchException(
294-
"Error loading inference for inference id [{}] on field [{}]",
295-
exc,
296-
inferenceId,
297-
request.field
298-
);
293+
failure = exc instanceof ElasticsearchException
294+
? exc
295+
: new ElasticsearchException(
296+
"Error loading inference for inference id [{}] on field [{}]",
297+
exc,
298+
inferenceId,
299+
request.field
300+
);
299301
}
300302
inferenceResults.get(request.index).failures.add(failure);
301303
}
@@ -319,12 +321,14 @@ public void onResponse(List<ChunkedInference> results) {
319321
var acc = inferenceResults.get(request.index);
320322
if (result instanceof ChunkedInferenceError error) {
321323
acc.addFailure(
322-
new ElasticsearchException(
323-
"Exception when running inference id [{}] on field [{}]",
324-
error.exception(),
325-
inferenceProvider.model.getInferenceEntityId(),
326-
request.field
327-
)
324+
error.exception() instanceof ElasticsearchException
325+
? error.exception()
326+
: new ElasticsearchException(
327+
"Exception when running inference id [{}] on field [{}]",
328+
error.exception(),
329+
inferenceProvider.model.getInferenceEntityId(),
330+
request.field
331+
)
328332
);
329333
} else {
330334
acc.addOrUpdateResponse(
@@ -351,12 +355,14 @@ public void onFailure(Exception exc) {
351355
for (FieldInferenceRequest request : requests) {
352356
addInferenceResponseFailure(
353357
request.index,
354-
new ElasticsearchException(
355-
"Exception when running inference id [{}] on field [{}]",
356-
exc,
357-
inferenceProvider.model.getInferenceEntityId(),
358-
request.field
359-
)
358+
exc instanceof ElasticsearchException
359+
? exc
360+
: new ElasticsearchException(
361+
"Exception when running inference id [{}] on field [{}]",
362+
exc,
363+
inferenceProvider.model.getInferenceEntityId(),
364+
request.field
365+
)
360366
);
361367
}
362368
} finally {

0 commit comments

Comments
 (0)