Skip to content

Conversation

Mikep86
Copy link
Contributor

@Mikep86 Mikep86 commented Apr 4, 2025

Updates InferenceException to retain the top-level message when converted to XContent. The purpose of InferenceException is to pass through the status of the cause while retaining the top-level message for better error traceability, which it wasn't doing before.

With this change, an InferenceException emitted to XContent looks like:

{
  "type": "inference_exception",
  "reason": "test wrapper",
  "caused_by": {
    "type": "status_exception", "reason": "test"
  }
}

@Mikep86 Mikep86 added >non-issue auto-backport Automatically create backport pull requests when merged :SearchOrg/Relevance Label for the Search (solution/org) Relevance team :Search Relevance/Search Catch all for Search Relevance v8.18.1 v8.19.0 v9.0.1 v9.1.0 v8.17.5 labels Apr 4, 2025
@Mikep86 Mikep86 requested a review from tteofili April 4, 2025 20:42
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/search-eng (Team:SearchOrg)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/search-relevance (Team:Search - Relevance)

Copy link
Member

@kderusso kderusso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Samiul-TheSoccerFan Samiul-TheSoccerFan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

public RestStatus status() {
// Override status so that we get the status of the cause while retaining the message of the inference exception when emitting to
// XContent
return ExceptionsHelper.status(getCause());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup! 👍

@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.18
8.x
9.0
8.17

Mikep86 added a commit to Mikep86/elasticsearch that referenced this pull request Apr 7, 2025
Mikep86 added a commit to Mikep86/elasticsearch that referenced this pull request Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >non-issue :Search Relevance/Search Catch all for Search Relevance :SearchOrg/Relevance Label for the Search (solution/org) Relevance team v8.17.5 v8.18.1 v8.19.0 v9.0.1 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants