-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Search Sessions] Improve search session errors (#88613)
* Detect ESError correctly Fix bfetch error (was recognized as unknown error) Make sure handleSearchError always returns an error object. * fix tests and improve types * type * normalize search error response format for search and bsearch * type * Added es search exception examples * Normalize and validate errors thrown from oss es_search_strategy Validate abort * Added tests for search service error handling * Update msearch tests to test for errors * Moved bsearch route to routes folder Adjusted bsearch response format Added verification of error's root cause * Align painless error object * eslint * Add to seach interceptor tests * add json to tsconfig * docs * updated xpack search strategy tests * oops * license header * Add test for xpack painless error format * doc * Fix bsearch test potential flakiness * code review * fix * code review 2 Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
52f5403
commit 841ab70
Showing
42 changed files
with
1,499 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/plugins/data/common/search/test_data/illegal_argument_exception.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"error" : { | ||
"root_cause" : [ | ||
{ | ||
"type" : "illegal_argument_exception", | ||
"reason" : "failed to parse setting [timeout] with value [1] as a time value: unit is missing or unrecognized" | ||
} | ||
], | ||
"type" : "illegal_argument_exception", | ||
"reason" : "failed to parse setting [timeout] with value [1] as a time value: unit is missing or unrecognized" | ||
}, | ||
"status" : 400 | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
src/plugins/data/common/search/test_data/index_not_found_exception.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"error" : { | ||
"root_cause" : [ | ||
{ | ||
"type" : "index_not_found_exception", | ||
"reason" : "no such index [poop]", | ||
"resource.type" : "index_or_alias", | ||
"resource.id" : "poop", | ||
"index_uuid" : "_na_", | ||
"index" : "poop" | ||
} | ||
], | ||
"type" : "index_not_found_exception", | ||
"reason" : "no such index [poop]", | ||
"resource.type" : "index_or_alias", | ||
"resource.id" : "poop", | ||
"index_uuid" : "_na_", | ||
"index" : "poop" | ||
}, | ||
"status" : 404 | ||
} |
14 changes: 14 additions & 0 deletions
14
src/plugins/data/common/search/test_data/json_e_o_f_exception.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"error" : { | ||
"root_cause" : [ | ||
{ | ||
"type" : "json_e_o_f_exception", | ||
"reason" : "Unexpected end-of-input: expected close marker for Object (start marker at [Source: (org.elasticsearch.common.io.stream.InputStreamStreamInput); line: 1, column: 1])\n at [Source: (org.elasticsearch.common.io.stream.InputStreamStreamInput); line: 1, column: 2]" | ||
} | ||
], | ||
"type" : "json_e_o_f_exception", | ||
"reason" : "Unexpected end-of-input: expected close marker for Object (start marker at [Source: (org.elasticsearch.common.io.stream.InputStreamStreamInput); line: 1, column: 1])\n at [Source: (org.elasticsearch.common.io.stream.InputStreamStreamInput); line: 1, column: 2]" | ||
}, | ||
"status" : 400 | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
src/plugins/data/common/search/test_data/parsing_exception.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"error" : { | ||
"root_cause" : [ | ||
{ | ||
"type" : "parsing_exception", | ||
"reason" : "[terms] query does not support [ohno]", | ||
"line" : 4, | ||
"col" : 17 | ||
} | ||
], | ||
"type" : "parsing_exception", | ||
"reason" : "[terms] query does not support [ohno]", | ||
"line" : 4, | ||
"col" : 17 | ||
}, | ||
"status" : 400 | ||
} |
13 changes: 13 additions & 0 deletions
13
src/plugins/data/common/search/test_data/resource_not_found_exception.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"error" : { | ||
"root_cause" : [ | ||
{ | ||
"type" : "resource_not_found_exception", | ||
"reason" : "FlZlSXp6dkd3UXdHZjhsalVtVHBnYkEdYjNIWDhDOTZRN3ExemdmVkx4RXNQQToxMjc2ODk=" | ||
} | ||
], | ||
"type" : "resource_not_found_exception", | ||
"reason" : "FlZlSXp6dkd3UXdHZjhsalVtVHBnYkEdYjNIWDhDOTZRN3ExemdmVkx4RXNQQToxMjc2ODk=" | ||
}, | ||
"status" : 404 | ||
} |
52 changes: 52 additions & 0 deletions
52
src/plugins/data/common/search/test_data/search_phase_execution_exception.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"error" : { | ||
"root_cause" : [ | ||
{ | ||
"type" : "script_exception", | ||
"reason" : "compile error", | ||
"script_stack" : [ | ||
"invalid", | ||
"^---- HERE" | ||
], | ||
"script" : "invalid", | ||
"lang" : "painless", | ||
"position" : { | ||
"offset" : 0, | ||
"start" : 0, | ||
"end" : 7 | ||
} | ||
} | ||
], | ||
"type" : "search_phase_execution_exception", | ||
"reason" : "all shards failed", | ||
"phase" : "query", | ||
"grouped" : true, | ||
"failed_shards" : [ | ||
{ | ||
"shard" : 0, | ||
"index" : ".kibana_11", | ||
"node" : "b3HX8C96Q7q1zgfVLxEsPA", | ||
"reason" : { | ||
"type" : "script_exception", | ||
"reason" : "compile error", | ||
"script_stack" : [ | ||
"invalid", | ||
"^---- HERE" | ||
], | ||
"script" : "invalid", | ||
"lang" : "painless", | ||
"position" : { | ||
"offset" : 0, | ||
"start" : 0, | ||
"end" : 7 | ||
}, | ||
"caused_by" : { | ||
"type" : "illegal_argument_exception", | ||
"reason" : "cannot resolve symbol [invalid]" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"status" : 400 | ||
} |
17 changes: 17 additions & 0 deletions
17
src/plugins/data/common/search/test_data/x_content_parse_exception.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"error" : { | ||
"root_cause" : [ | ||
{ | ||
"type" : "x_content_parse_exception", | ||
"reason" : "[5:13] [script] failed to parse object" | ||
} | ||
], | ||
"type" : "x_content_parse_exception", | ||
"reason" : "[5:13] [script] failed to parse object", | ||
"caused_by" : { | ||
"type" : "json_parse_exception", | ||
"reason" : "Unexpected character (''' (code 39)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (org.elasticsearch.common.bytes.AbstractBytesReference$BytesReferenceStreamInput); line: 5, column: 24]" | ||
} | ||
}, | ||
"status" : 400 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/plugins/data/public/search/errors/painless_error.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* and the Server Side Public License, v 1; you may not use this file except in | ||
* compliance with, at your election, the Elastic License or the Server Side | ||
* Public License, v 1. | ||
*/ | ||
|
||
import { coreMock } from '../../../../../core/public/mocks'; | ||
const startMock = coreMock.createStart(); | ||
|
||
import { mount } from 'enzyme'; | ||
import { PainlessError } from './painless_error'; | ||
import { findTestSubject } from '@elastic/eui/lib/test'; | ||
import * as searchPhaseException from '../../../common/search/test_data/search_phase_execution_exception.json'; | ||
|
||
describe('PainlessError', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('Should show reason and code', () => { | ||
const e = new PainlessError({ | ||
statusCode: 400, | ||
message: 'search_phase_execution_exception', | ||
attributes: searchPhaseException.error, | ||
}); | ||
const component = mount(e.getErrorMessage(startMock.application)); | ||
|
||
const scriptElem = findTestSubject(component, 'painlessScript').getDOMNode(); | ||
|
||
const failedShards = e.attributes?.failed_shards![0]; | ||
const script = failedShards!.reason.script; | ||
expect(scriptElem.textContent).toBe(`Error executing Painless script: '${script}'`); | ||
|
||
const stackTraceElem = findTestSubject(component, 'painlessStackTrace').getDOMNode(); | ||
const stackTrace = failedShards!.reason.script_stack!.join('\n'); | ||
expect(stackTraceElem.textContent).toBe(stackTrace); | ||
|
||
expect(component.find('EuiButton').length).toBe(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.