Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search Sessions] Improve search session errors #88613

Merged
merged 46 commits into from
Jan 31, 2021

Conversation

lizozom
Copy link
Contributor

@lizozom lizozom commented Jan 18, 2021

Resolves #88570

  • Normalizes and adds test (unit and api integration) to the error format returned from the server for search, msearch, async_search and bsearch. The new format is
{
    statusCode: number;
    message: string;
    attributes?: T
}
  • Adds actual elasticsearch resopnses for better testing

While before, the error messages were not shown, now the errors look like this:

image
image

Summary

Summarize your PR. If it involves visual changes include a screenshot or gif.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

Fix bfetch error (was recognized as unknown error)
Make sure handleSearchError always returns an error object.
@lizozom lizozom requested a review from a team as a code owner January 18, 2021 16:07
@lizozom lizozom self-assigned this Jan 18, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@lizozom lizozom changed the title Improve search session errors [Search Sessions] Improve search session errors Jan 18, 2021
@lizozom lizozom added the release_note:skip Skip the PR/issue when compiling release notes label Jan 18, 2021
@Dosant
Copy link
Contributor

Dosant commented Jan 18, 2021

Noticed a problem with scripted field error:

Branch:

Screenshot 2021-01-18 at 17 36 38

Master:

Screenshot 2021-01-18 at 17 51 33


probably worth checking other special cases, like maybe, shards failures and request timeouts

@lizozom lizozom marked this pull request as draft January 20, 2021 19:55
@lizozom
Copy link
Contributor Author

lizozom commented Jan 27, 2021

@elasticmachine merge upstream

@elastic elastic deleted a comment from alonxprt Jan 27, 2021
Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

Overall, LGTM. Left a couple of comments below.

src/plugins/kibana_utils/common/errors/types.ts Outdated Show resolved Hide resolved
try {
await esClient.asCurrentUser.asyncSearch.delete({ id });
} catch (e) {
throw getKbnServerError(e);
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth updating the other search strategies, or at least letting them know that this is the preferred way to handle errors?

Copy link
Contributor

@Dosant Dosant left a comment

Choose a reason for hiding this comment

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

in general LGTM. great effort and love all tests!

Some feedback:

  1. Noticed one empty fail that seems to be not used:
    src/plugins/data/common/search/test_data/illegal_state_exception.json

  2. It seems that any usage grew up? I would really like it if we could avoid that. For example, I think, that toKibanaServerError should handle unknown and do all needed runtime checks inside

  3. Since this affects all data plugin consumers and errors are something that is often skipped in automated tests, do you think it makes sense to ask some of the plugin consumers teams to test this also in their apps? Maybe someone implicitly relies somewhere on older error formats.

@@ -24,7 +24,7 @@ export enum TimeoutErrorMode {
*/
export class SearchTimeoutError extends KbnError {
public mode: TimeoutErrorMode;
constructor(err: Error, mode: TimeoutErrorMode) {
constructor(err: Record<string, any>, mode: TimeoutErrorMode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change necessary?
Looks like we creating SearchTimeoutError where we known we are passing KibanaServerError
Could it be KibanaServerError then?

src/plugins/data/public/search/search_interceptor.ts Outdated Show resolved Hide resolved
src/plugins/data/public/search/search_interceptor.ts Outdated Show resolved Hide resolved
src/plugins/data/server/search/routes/bsearch.ts Outdated Show resolved Hide resolved
test/api_integration/apis/search/bsearch.ts Outdated Show resolved Hide resolved
@lizozom
Copy link
Contributor Author

lizozom commented Jan 28, 2021

@elasticmachine merge upstream

@lizozom
Copy link
Contributor Author

lizozom commented Jan 28, 2021

@elasticmachine merge upstream

@lizozom
Copy link
Contributor Author

lizozom commented Jan 29, 2021

@elasticmachine merge upstream

@lizozom
Copy link
Contributor Author

lizozom commented Jan 31, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

expected head sha didn’t match current head ref.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
kibanaUtils 192 193 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
kibanaUtils 123.2KB 123.2KB +13.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 799.3KB 798.5KB -830.0B
kibanaUtils 142.1KB 154.5KB +12.4KB
total +11.6KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@lizozom lizozom merged commit 841ab70 into elastic:master Jan 31, 2021
lizozom added a commit to lizozom/kibana that referenced this pull request Jan 31, 2021
* 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>
lizozom added a commit that referenced this pull request Jan 31, 2021
* 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>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Search Querying infrastructure in Kibana release_note:skip Skip the PR/issue when compiling release notes v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SearchSessions] Improve the restore errors on Discover and Dashboard
5 participants