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

[Security Solutions] Critical bug to add network responses to error toasters #97945

Merged

Conversation

FrankHassanabad
Copy link
Contributor

@FrankHassanabad FrankHassanabad commented Apr 22, 2021

Summary

When we updated our codebase to use the newer bsearch/async search, we ended up using error messages which were not the same as we had before which would show the network errors in the full message when the "see full error button" was clicked.

This has been bad lately as users and quality assurance people have been posting screen shots that have very little information, blank error messages, and/or stack traces instead of network errors. This makes them think the code has issues when it is a configuration issue or a networking issue that is happening.

This PR does the following:

  • Changes all the bsearch queries to use the use useAppToasts
  • Modifies the useAppToasts to be able to transform bsearch with the kibana global notification
  • Cleans up the useAppToasts some
  • Deprecates the GlobalErrorToaster in favor of the useAppToasts
  • Fixes and adds a few i18n missing strings found
  • Removes most of the deprecated error dispatch toasters from detection_engine except for 1 place where it is not a hook.

Before screen shot of errors with no buttons and messages that were not pointing to network errors:
Screen Shot 2021-04-21 at 4 24 45 PM

After screen shot where you have a button and that button will show you the network error:
Screen Shot 2021-04-21 at 3 26 12 PM

Screen Shot 2021-04-21 at 3 26 21 PM

You can manually test this easily by making non ECS indexes to cause errors and then add them as a kibana index and use them in the data sourcer.

Checklist

@FrankHassanabad FrankHassanabad self-assigned this Apr 22, 2021
@FrankHassanabad FrankHassanabad changed the title [Security Solutions] Adds network responses to our error messaging [Security Solutions] Critical bug where we do not have network responses for our error messaging Apr 22, 2021
@FrankHassanabad FrankHassanabad changed the title [Security Solutions] Critical bug where we do not have network responses for our error messaging [Security Solutions] Critical bug to add network responses to error toasters Apr 22, 2021
@FrankHassanabad FrankHassanabad marked this pull request as ready for review April 22, 2021 03:14
@FrankHassanabad FrankHassanabad requested a review from a team as a code owner April 22, 2021 03:14
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

const err = esErrorToRequestError(error);
return addError(err, options);
} else if (isAppError(error)) {
return addError(error, options);
Copy link
Contributor Author

@FrankHassanabad FrankHassanabad Apr 22, 2021

Choose a reason for hiding this comment

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

One note @rylnd is that I chose to change this to use the default of error.message which is the toaster default to use if it is not given an explicit toastMessage.

I don't know if there was a reason to prefer using the error.body.message when it is an AppError for example that I'm not seeing or what the difference is?

Copy link
Contributor

Choose a reason for hiding this comment

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

@FrankHassanabad the old test seemed to indicate that body.message contained a more detailed message. Had you seen anything for/against that assertion?

Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. the message field was just a restatement of the status code, while body.message contained an actual reason.

@@ -96,15 +98,13 @@ export const useTimelineLastEventTime = ({
}));
} else if (isErrorResponse(response)) {
setLoading(false);
// TODO: Make response error status clearer
notifications.toasts.addWarning(i18n.ERROR_LAST_EVENT_TIME);
addWarning(i18n.ERROR_LAST_EVENT_TIME);
}
},
error: (msg) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We're still not able to type this are we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand what you're saying correct, we are not able to ingest a partial error/response at this moment which is correct.

addWarning(i18n.ERROR_LAST_EVENT_TIME);

That warning isn't going to be great. However, I also haven't seen that much if any at all and couldn't trip it during testing. I really don't know if/when it gets tripped to be totally honest. I think if we see that happening or we dig into it, we should make a follow up PR where we can add the response into the warning object and then push it onto the toaster if possible:

addWarning(response, i18n.ERROR_LAST_EVENT_TIME);

But won't be soon :-) (at least from myself)

Copy link
Contributor

@yctercero yctercero left a comment

Choose a reason for hiding this comment

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

This is really huge. I checked out and tested on preview, hosts, and a few others. My only super duper minor comment would be maybe we could just add a use_app_toats.mock.ts as some itty bitty cleanup 😄 This is awesome, thanks Frank.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 2151 2153 +2

Async chunks

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

id before after diff
securitySolution 6.9MB 6.9MB +1.4KB

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

cc @FrankHassanabad

@FrankHassanabad
Copy link
Contributor Author

@yara this is a mock:
x-pack/plugins/security_solution/public/common/hooks/use_app_toasts.mock.ts

I use it in a few areas and then in some areas, I use the existing ways of mocking things.

@FrankHassanabad FrankHassanabad added the auto-backport Deprecated - use backport:version if exact versions are needed label Apr 22, 2021
@FrankHassanabad FrankHassanabad merged commit 2f679e6 into elastic:master Apr 22, 2021
@FrankHassanabad FrankHassanabad deleted the add-better-error-handling branch April 22, 2021 14:57
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 22, 2021
…oasters (elastic#97945)

## Summary

When we updated our codebase to use the newer bsearch/async search, we ended up using error messages which were not the same as we had before which would show the network errors in the full message when the "see full error button" was clicked.

This has been bad lately as users and quality assurance people have been posting screen shots that have very little information, blank error messages, and/or stack traces instead of network errors. This makes them think the code has issues when it is a configuration issue or a networking issue that is happening.

This PR does the following:
* Changes all the bsearch queries to use the use useAppToasts
* Modifies the useAppToasts to be able to transform bsearch with the kibana global notification
* Cleans up the useAppToasts some
* Deprecates the GlobalErrorToaster in favor of the useAppToasts
* Fixes and adds a few i18n missing strings found
* Removes most of the deprecated error dispatch toasters from detection_engine except for 1 place where it is not a hook.
 
Before screen shot of errors with no buttons and messages that were not pointing to network errors:
<img width="422" alt="Screen Shot 2021-04-21 at 4 24 45 PM" src="https://user-images.githubusercontent.com/1151048/115642119-9a942300-a2d7-11eb-955a-b51097a8d3ec.png">


After screen shot where you have a button and that button will show you the network error:
<img width="395" alt="Screen Shot 2021-04-21 at 3 26 12 PM" src="https://user-images.githubusercontent.com/1151048/115642216-c6170d80-a2d7-11eb-8c94-0a1c15186fab.png">

<img width="786" alt="Screen Shot 2021-04-21 at 3 26 21 PM" src="https://user-images.githubusercontent.com/1151048/115642222-ca432b00-a2d7-11eb-9ddd-4ed6c6270b94.png">

You can manually test this easily by making non ECS indexes to cause errors and then add them as a kibana index and use them in the data sourcer.

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.13

This backport PR will be merged automatically after passing CI.

@@ -37,31 +38,36 @@ describe('useDeleteList', () => {
expect(addErrorMock).toHaveBeenCalledWith(error, { title: 'title' });
});

it("uses a AppError's body.message as the toastMessage", async () => {
const kibanaApiError = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This kibanaApiError was a representative error type that we intended to handle, so it's surprising to see support for it dropped here. Did we verify that this is no longer an error that we encounter/support?

kibanamachine added a commit that referenced this pull request Apr 22, 2021
…oasters (#97945) (#98029)

## Summary

When we updated our codebase to use the newer bsearch/async search, we ended up using error messages which were not the same as we had before which would show the network errors in the full message when the "see full error button" was clicked.

This has been bad lately as users and quality assurance people have been posting screen shots that have very little information, blank error messages, and/or stack traces instead of network errors. This makes them think the code has issues when it is a configuration issue or a networking issue that is happening.

This PR does the following:
* Changes all the bsearch queries to use the use useAppToasts
* Modifies the useAppToasts to be able to transform bsearch with the kibana global notification
* Cleans up the useAppToasts some
* Deprecates the GlobalErrorToaster in favor of the useAppToasts
* Fixes and adds a few i18n missing strings found
* Removes most of the deprecated error dispatch toasters from detection_engine except for 1 place where it is not a hook.
 
Before screen shot of errors with no buttons and messages that were not pointing to network errors:
<img width="422" alt="Screen Shot 2021-04-21 at 4 24 45 PM" src="https://user-images.githubusercontent.com/1151048/115642119-9a942300-a2d7-11eb-955a-b51097a8d3ec.png">


After screen shot where you have a button and that button will show you the network error:
<img width="395" alt="Screen Shot 2021-04-21 at 3 26 12 PM" src="https://user-images.githubusercontent.com/1151048/115642216-c6170d80-a2d7-11eb-8c94-0a1c15186fab.png">

<img width="786" alt="Screen Shot 2021-04-21 at 3 26 21 PM" src="https://user-images.githubusercontent.com/1151048/115642222-ca432b00-a2d7-11eb-9ddd-4ed6c6270b94.png">

You can manually test this easily by making non ECS indexes to cause errors and then add them as a kibana index and use them in the data sourcer.

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios

Co-authored-by: Frank Hassanabad <[email protected]>
FrankHassanabad added a commit that referenced this pull request Apr 26, 2021
…rs and error messages (#98220)

## Summary

Follow up from feedback and testing of:
#97945

This fixes a bug found with the older toaster notifications that can cause a screen stack trace:
<img width="1520" alt="Screen Shot 2021-04-22 at 5 32 57 PM" src="https://user-images.githubusercontent.com/1151048/115929514-2d9e9b80-a445-11eb-8017-eb21d800c472.png">

Adds more information and robust error handling when the messages are Kibana/NodeJS error messages.

Before:
<img width="808" alt="Screen Shot 2021-04-22 at 5 37 37 PM" src="https://user-images.githubusercontent.com/1151048/115929643-5de63a00-a445-11eb-93bc-5a826f371ef3.png">
After:
<img width="789" alt="Screen Shot 2021-04-22 at 6 23 52 PM" src="https://user-images.githubusercontent.com/1151048/115929651-62aaee00-a445-11eb-9c03-d56b488d238b.png">

### Checklist
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 26, 2021
…rs and error messages (elastic#98220)

## Summary

Follow up from feedback and testing of:
elastic#97945

This fixes a bug found with the older toaster notifications that can cause a screen stack trace:
<img width="1520" alt="Screen Shot 2021-04-22 at 5 32 57 PM" src="https://user-images.githubusercontent.com/1151048/115929514-2d9e9b80-a445-11eb-8017-eb21d800c472.png">

Adds more information and robust error handling when the messages are Kibana/NodeJS error messages.

Before:
<img width="808" alt="Screen Shot 2021-04-22 at 5 37 37 PM" src="https://user-images.githubusercontent.com/1151048/115929643-5de63a00-a445-11eb-93bc-5a826f371ef3.png">
After:
<img width="789" alt="Screen Shot 2021-04-22 at 6 23 52 PM" src="https://user-images.githubusercontent.com/1151048/115929651-62aaee00-a445-11eb-9c03-d56b488d238b.png">

### Checklist
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Apr 26, 2021
…oasters (elastic#97945)

## Summary

When we updated our codebase to use the newer bsearch/async search, we ended up using error messages which were not the same as we had before which would show the network errors in the full message when the "see full error button" was clicked.

This has been bad lately as users and quality assurance people have been posting screen shots that have very little information, blank error messages, and/or stack traces instead of network errors. This makes them think the code has issues when it is a configuration issue or a networking issue that is happening.

This PR does the following:
* Changes all the bsearch queries to use the use useAppToasts
* Modifies the useAppToasts to be able to transform bsearch with the kibana global notification
* Cleans up the useAppToasts some
* Deprecates the GlobalErrorToaster in favor of the useAppToasts
* Fixes and adds a few i18n missing strings found
* Removes most of the deprecated error dispatch toasters from detection_engine except for 1 place where it is not a hook.
 
Before screen shot of errors with no buttons and messages that were not pointing to network errors:
<img width="422" alt="Screen Shot 2021-04-21 at 4 24 45 PM" src="https://user-images.githubusercontent.com/1151048/115642119-9a942300-a2d7-11eb-955a-b51097a8d3ec.png">


After screen shot where you have a button and that button will show you the network error:
<img width="395" alt="Screen Shot 2021-04-21 at 3 26 12 PM" src="https://user-images.githubusercontent.com/1151048/115642216-c6170d80-a2d7-11eb-8c94-0a1c15186fab.png">

<img width="786" alt="Screen Shot 2021-04-21 at 3 26 21 PM" src="https://user-images.githubusercontent.com/1151048/115642222-ca432b00-a2d7-11eb-9ddd-4ed6c6270b94.png">

You can manually test this easily by making non ECS indexes to cause errors and then add them as a kibana index and use them in the data sourcer.

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
kibanamachine added a commit that referenced this pull request Apr 27, 2021
…rs and error messages (#98220) (#98429)

## Summary

Follow up from feedback and testing of:
#97945

This fixes a bug found with the older toaster notifications that can cause a screen stack trace:
<img width="1520" alt="Screen Shot 2021-04-22 at 5 32 57 PM" src="https://user-images.githubusercontent.com/1151048/115929514-2d9e9b80-a445-11eb-8017-eb21d800c472.png">

Adds more information and robust error handling when the messages are Kibana/NodeJS error messages.

Before:
<img width="808" alt="Screen Shot 2021-04-22 at 5 37 37 PM" src="https://user-images.githubusercontent.com/1151048/115929643-5de63a00-a445-11eb-93bc-5a826f371ef3.png">
After:
<img width="789" alt="Screen Shot 2021-04-22 at 6 23 52 PM" src="https://user-images.githubusercontent.com/1151048/115929651-62aaee00-a445-11eb-9c03-d56b488d238b.png">

### Checklist
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios

Co-authored-by: Frank Hassanabad <[email protected]>
FrankHassanabad added a commit that referenced this pull request Apr 27, 2021
…oasters (#97945) (#98430)

## Summary

When we updated our codebase to use the newer bsearch/async search, we ended up using error messages which were not the same as we had before which would show the network errors in the full message when the "see full error button" was clicked.

This has been bad lately as users and quality assurance people have been posting screen shots that have very little information, blank error messages, and/or stack traces instead of network errors. This makes them think the code has issues when it is a configuration issue or a networking issue that is happening.

This PR does the following:
* Changes all the bsearch queries to use the use useAppToasts
* Modifies the useAppToasts to be able to transform bsearch with the kibana global notification
* Cleans up the useAppToasts some
* Deprecates the GlobalErrorToaster in favor of the useAppToasts
* Fixes and adds a few i18n missing strings found
* Removes most of the deprecated error dispatch toasters from detection_engine except for 1 place where it is not a hook.
 
Before screen shot of errors with no buttons and messages that were not pointing to network errors:
<img width="422" alt="Screen Shot 2021-04-21 at 4 24 45 PM" src="https://user-images.githubusercontent.com/1151048/115642119-9a942300-a2d7-11eb-955a-b51097a8d3ec.png">


After screen shot where you have a button and that button will show you the network error:
<img width="395" alt="Screen Shot 2021-04-21 at 3 26 12 PM" src="https://user-images.githubusercontent.com/1151048/115642216-c6170d80-a2d7-11eb-8c94-0a1c15186fab.png">

<img width="786" alt="Screen Shot 2021-04-21 at 3 26 21 PM" src="https://user-images.githubusercontent.com/1151048/115642222-ca432b00-a2d7-11eb-9ddd-4ed6c6270b94.png">

You can manually test this easily by making non ECS indexes to cause errors and then add them as a kibana index and use them in the data sourcer.

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Apr 27, 2021
…rs and error messages (elastic#98220)

## Summary

Follow up from feedback and testing of:
elastic#97945

This fixes a bug found with the older toaster notifications that can cause a screen stack trace:
<img width="1520" alt="Screen Shot 2021-04-22 at 5 32 57 PM" src="https://user-images.githubusercontent.com/1151048/115929514-2d9e9b80-a445-11eb-8017-eb21d800c472.png">

Adds more information and robust error handling when the messages are Kibana/NodeJS error messages.

Before:
<img width="808" alt="Screen Shot 2021-04-22 at 5 37 37 PM" src="https://user-images.githubusercontent.com/1151048/115929643-5de63a00-a445-11eb-93bc-5a826f371ef3.png">
After:
<img width="789" alt="Screen Shot 2021-04-22 at 6 23 52 PM" src="https://user-images.githubusercontent.com/1151048/115929651-62aaee00-a445-11eb-9c03-d56b488d238b.png">

### Checklist
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
FrankHassanabad added a commit that referenced this pull request Apr 27, 2021
…rs and error messages (#98220) (#98435)

## Summary

Follow up from feedback and testing of:
#97945

This fixes a bug found with the older toaster notifications that can cause a screen stack trace:
<img width="1520" alt="Screen Shot 2021-04-22 at 5 32 57 PM" src="https://user-images.githubusercontent.com/1151048/115929514-2d9e9b80-a445-11eb-8017-eb21d800c472.png">

Adds more information and robust error handling when the messages are Kibana/NodeJS error messages.

Before:
<img width="808" alt="Screen Shot 2021-04-22 at 5 37 37 PM" src="https://user-images.githubusercontent.com/1151048/115929643-5de63a00-a445-11eb-93bc-5a826f371ef3.png">
After:
<img width="789" alt="Screen Shot 2021-04-22 at 6 23 52 PM" src="https://user-images.githubusercontent.com/1151048/115929651-62aaee00-a445-11eb-9c03-d56b488d238b.png">

### Checklist
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:fix Team:Detections and Resp Security Detection Response Team v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants