Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/123890.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 123890
summary: Do not let `ShardBulkInferenceActionFilter` unwrap / rewrap ESExceptions
area: Search
type: bug
issues: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.inference;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchWrapperException;

public class InferenceException extends ElasticsearchException implements ElasticsearchWrapperException {
public InferenceException(String message, Throwable cause, Object... args) {
super(message, cause, args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package org.elasticsearch.xpack.inference.action.filter;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.ResourceNotFoundException;
Expand Down Expand Up @@ -45,6 +44,7 @@
import org.elasticsearch.xcontent.XContent;
import org.elasticsearch.xpack.core.XPackField;
import org.elasticsearch.xpack.core.inference.results.ChunkedInferenceError;
import org.elasticsearch.xpack.inference.InferenceException;
import org.elasticsearch.xpack.inference.mapper.SemanticTextField;
import org.elasticsearch.xpack.inference.mapper.SemanticTextFieldMapper;
import org.elasticsearch.xpack.inference.mapper.SemanticTextUtils;
Expand Down Expand Up @@ -288,7 +288,7 @@ public void onFailure(Exception exc) {
request.field
);
} else {
failure = new ElasticsearchException(
failure = new InferenceException(
"Error loading inference for inference id [{}] on field [{}]",
exc,
inferenceId,
Expand Down Expand Up @@ -317,7 +317,7 @@ public void onResponse(List<ChunkedInference> results) {
var acc = inferenceResults.get(request.index);
if (result instanceof ChunkedInferenceError error) {
acc.addFailure(
new ElasticsearchException(
new InferenceException(
"Exception when running inference id [{}] on field [{}]",
error.exception(),
inferenceProvider.model.getInferenceEntityId(),
Expand Down Expand Up @@ -349,7 +349,7 @@ public void onFailure(Exception exc) {
for (FieldInferenceRequest request : requests) {
addInferenceResponseFailure(
request.index,
new ElasticsearchException(
new InferenceException(
"Exception when running inference id [{}] on field [{}]",
exc,
inferenceProvider.model.getInferenceEntityId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ public void testItemFailures() throws Exception {
assertNotNull(bulkShardRequest.items()[0].getPrimaryResponse());
assertTrue(bulkShardRequest.items()[0].getPrimaryResponse().isFailed());
BulkItemResponse.Failure failure = bulkShardRequest.items()[0].getPrimaryResponse().getFailure();
assertThat(failure.getCause().getMessage(), containsString("Exception when running inference"));
assertThat(failure.getCause().getCause().getMessage(), containsString("boom"));
assertThat(failure.getStatus(), is(RestStatus.BAD_REQUEST));

// item 1 is a success
assertNull(bulkShardRequest.items()[1].getPrimaryResponse());
Expand All @@ -267,7 +269,9 @@ public void testItemFailures() throws Exception {
assertNotNull(bulkShardRequest.items()[2].getPrimaryResponse());
assertTrue(bulkShardRequest.items()[2].getPrimaryResponse().isFailed());
failure = bulkShardRequest.items()[2].getPrimaryResponse().getFailure();
assertThat(failure.getCause().getMessage(), containsString("Exception when running inference"));
assertThat(failure.getCause().getCause().getMessage(), containsString("boom"));
assertThat(failure.getStatus(), is(RestStatus.BAD_REQUEST));
} finally {
chainExecuted.countDown();
}
Expand Down