* Convert our manual throwing of TypeError to a custom Error
Throwing a TypeError meant that our manual errors were indistinguishable
from, say, trying to invoke a method on undefined. This adds a custom
error, BadRequestError, that disambiguates that situation.
* Present API Error messages to the user
With Core's new HTTP client, an unsuccessful API call will raise an
error containing the body of the response it received. In the case of
SIEM endpoints, this will include a useful error message with
potentially more specificity than e.g. 'Internal Server Error'.
This adds a type predicate to check for such errors, and adds a handling
case in our errorToToaster handler.
If the error does not contain our SIEM-specific message, it will fall
through as normal and the general error.message will be displayed in the
toaster.
* Remove unnecessary use of throwIfNotOk in our client API calls
The new HTTP client raises an error on a 4xx or 5xx response, so there
should not be a case where throwIfNotOk is actually going to throw an
error.
The established pattern on the frontend is to catch errors at the call
site and handle them appropriately, so I'm mainly just verifying that
these are caught where they're used, now.
* Move errorToToaster and ToasterError to general location
These were living in ML since that's where they originated. However, we
have need of it (and already use it) elsewhere.
The basic pattern for error handling on the frontend is:
1) API call throws error
2) caller catches error and dispatches a toast
throwIfNotOk is meant to convert the error into a useful message in 1).
We currently use both errorToToaster and displayErrorToast to display
that in a toaster in 2)
Now that errorToToaster handles a few different types of errors, and
throwIfNotOk is going to be bypassed due to the new client behavior of
throwing on error, we're going to start consolidating on:
1) Api call throws error
2) caller catches error and passes it to errorToToaster
* Refactor Rules API functions to not use throwIfNotOk
* Ensures that all callers of these methods properly catch errors
* Updates error toasterification to use errorToToaster
* Simplifies tests now that we mainly just invoke the http client and
return the result.
throwIfNotOk is not being used in the majority of cases, as the client
raises an error and bypasses that call.
The few cases this might break are where we return a 200 but have errors
within the response. Whether throwIfNotOk handled this or not, I'll need
a simpler helper to accomplish the same behavior.
* Define a type for our BulkRule responses
These can be an array of errors OR rules; typing it as such forces
downstream to deal with both. enableRules was being handled correctly
with the bucketing helper, and TS has confirmed the rest are as well.
This obviates the need to raise from our API calls, as bulk errors are
recoverable and we want to both a) continue on with any successful rules
and b) handle the errors as necessary. This is highly dependent on the
caller and so we can't/shouldn't handle it here.
* Address case where bulk rules errors were not handled
I'm not sure that we're ever using this non-dispatch version, but it was
throwing a type error. Will bring it up in review.
* Remove more throwIfNotOk uses from API calls
These are unneeded as an error response will already throw an error to
be handled at the call site.
* Display an error toaster on newsfeed fetch failure
* Remove dead code
This was left over as a result of #56261
* Remove throwIfNotOk from case API calls
Again, not needed because the client already throws.
* Update use_get_tags for NP
* Gets rid of throwIfNotOK usage
* uses core http fetch
* Remove throwIfNotOk from signals API
* Remove throwIfNotOk
This served the same purpose as errorToToaster, but in a less robust
way. All usages have been replaced, so now we say goodbye.
* Remove custom errors in favor of KibanaApiError and isApiError type predicate
There was no functional difference between these two code paths, and
removing these custom errors allowed us to delete a bunch of associated
code as well..
* Fix test failures
These were mainly related to my swapping any remaining fetch calls with
the core router as good kibana denizens should :salute:
* Replace use of core mocks with our simpler local ones
This is enough to get our tests to pass. We can't use the core mocks for
now since there are circular dependencies there, which breaks our build.
* add signal api unit tests
* privilege unit test api
* Add unit tests on the signals container
* Refactor signals API tests to use core mocks
* Simplifies our mocking verbosity by leveraging core mocks
* Simplifies test setup by isolating a reference to our fetch mock
* Abstracts response structure to pure helper functions
The try/catch tests had some false positives in that nothing would be
asserted if the code did not throw an error. These proved to be masking
a gap in coverage for our get/create signal index requests, which do not
leverage `throwIfNotOk` but instead rely on the fetch to throw an error;
once that behavior is verified we can update those tests to have our
fetchMock throw errors, and we should be all set.
* Simplify signals API tests now that the subjects do less
We no longer re-throw errors, or parse the response, we just return the
result of the client call. Simple!
* Simplify API functions to use implict returns
When possible. Also adds missing error-throwing documentation where
necessary.
* Revert "Display an error toaster on newsfeed fetch failure"
This reverts commit 64213221f5.
* Error property is readonly
* Pull uuid generation into default argument value
* Fix type predicate isApiError
Uses has to properly inspect our errorish object. Turns out we have a
'message' property, not an 'error' property.
* Fix test setup following modification of type predicate
We need a message (via new Error), a body.message, and a
body.status_code to satisfy isApiError.
Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
in cytoscape graph. Also selects root nodes with no incoming edges
rather than just unconnected nodes.
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
When only one node is displayed, show an empty message.
Also:
* Start adding a basic Jest test for the ServiceMap component
* Fix bug where EuiDocsLink was rendering "children" instead of the actual children
Closes#59326.
Closes#59128.
Migrates the client side plugin of transforms to NP.
- Gets rid of the last parts of the shim (http, documentation links)
- Moves the plugin from x-pack/legacy/plugins/transform/public to x-pack/plugins/transform
- Creates a custom mock for appDependencies based on NP services
- Fixes jest tests to get rid of all act() related warnings
## [SIEM] Fixes dragging entries to the Timeline while data is loading may trigger a partial page reload
The `react-beautiful-dnd` library, upgraded during the `7.6` stack release from
`10.0.1` to `12.2.0`, includes a breaking change to the way [errors are handled](https://github.com/atlassian/react-beautiful-dnd/blob/v12.0.0/docs/guides/setup-problem-detection-and-error-recovery.md)
and recovered. As a result of this change, an uncaught error may trigger a
an effect that feels (from the perspective of a user) like a partial page
reload.
The most common condition where this can occur is when dragging entries to the
Timeline while data is loading, per the animated gif below:
![refresh-error](https://user-images.githubusercontent.com/4459398/76016029-59755f80-5ed9-11ea-858d-cb1189d22ea9.gif)
## Reproduction steps
1. Navigate to the Hosts page
2. Open the Timeline
3. Drag a host to the Timeline
4. While data is still loading, drag a different host to the Timeline to create an `or` query
**Expected Results**
* The page does not appear to reload
* In development mode, a single error is logged to the JS console
**Actual Results**
* The page appears to reload
* In development mode, two errors are logged to the JS console
**Error 1**
```
react-beautiful-dnd
Invariant failed: Cannot find droppable entry with id [droppableId.content.event-details-value-default-draggable-plain-column-renderer-formatted-field-value-timeline-1-kLGooXABOOUskGlPiQw5-@timestamp-1583260131000]👷<200d> This is a development only message. It will be removed in production builds.
in Draggable (created by ConnectFunction)
in ConnectFunction (created by PrivateDraggable)
in PrivateDraggable (created by PublicDraggable)
in PublicDraggable (created by Droppable)
in Droppable (created by ConnectFunction)
in ConnectFunction
```
**Error 2**
```
react-beautiful-dnd
Invariant failed: Cannot find droppable entry with id [droppableId.content.event-details-value-default-draggable-plain-column-renderer-formatted-field-value-timeline-1-kLGooXABOOUskGlPiQw5-@timestamp-1583260131000]👷<200d> This is a development only message. It will be removed in production builds.
in ErrorBoundary (created by DragDropContext)
in DragDropContext (created by Anonymous)
in Anonymous
```
### Desk testing
Tested locally in:
* Chrome `80.0.3987.122`
* Firefox `73.0.1`
* Safari `13.0.5`
Fixes https://github.com/elastic/kibana/issues/59466
* [Reporting] Handle error if intercepted request could not be continued
* [Reporting/Screenshots] Handle page setup errors and capture the page with errors shown
* show warnings in UI
* i18n todos
* Cleanup an old troubleshooting task
* set the default for all new timeout settings to 30 seconds
* fix some tests
* update error strings
* Cleanup 2
* fix tests 2
* polish the job info map status items
* More error message updating
* Log the error that was caught
* Oops fix ts
* add documentation
* fix i18n
* fix mocha test
* use the openUrl timeout as the default for navigation
* fix comment
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* refactor to use io-ts, to be able to have ressource with sub, add total comments via comment_ids, be able to delete multiple cases/comments
* fix test
* adapt UI to refactor of the API
* put it back the way it was
* clean up to get cases
* review I
* review II - bring back url parameter
* fix merge
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* [Maps] top term percentage property
* populate percentage in feature properties
* TS work
* clean up TS
* fix all type errors
* unit test for esAggFieldsFactory
* clean up
* i18n cleanup
* do not show decimal place for perentage
* fix jest expects
* fix eslint errors
* tslint errors
* handle empty top bucket aggregation
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* Updated EUI to 20.0.1; updated typescript usage
* snapshots
* Upgrade to eui 20.0.2, fix one more type
* PR feedback
* Update EUI icon usage to the correct types
* Updated with master
- Deprecates the custom KibanaContext.
- Where applicable dependencies provided via KibanaContext are now passed on via AppDependencies.
- The main feature of KibanaContext was to populate index pattern and saved search information for the transform wizard. This is now provided via the useSearchItems() custom hook.
* Add direct access link registry and dashboard impl and use in ML
* Add example plugin with migration example
* address code review comments
* Fixes, more code review updates
* Readme clean up
* add tests
* remove else
* Rename everything from DirectAccessLinkGenerator to the much short UrlGenerator. also fix the ml # thing and return a relative link from dashboard genrator
* add important text in bold
* Move url generators into share plugin
* add correct i18n prefix
* Fix timeRange url name
* make share plugin optional for dashboard
* fix code owners
* Use base UrlGeneratorState type, add comments
* Fix hash bug and add test that would have caught it
* Pull core service init out into separate function
* Call bind function from embeddable factory constructor
* Move inspector init back to start method. Remove old license check file
* Add TS types
- Deprecates the custom KibanaContext.
- Where applicable dependencies provided via KibanaContext are now passed on via AppDependencies.
- The main feature of KibanaContext was to populate index pattern and saved search information for the transform wizard. This is now provided via the useSearchItems() custom hook.
* wip
* review follow up
* make ACTION a prefix, not SUFFIX
* fix path
* add warnings about casting to ActionType
* Make context an object in examples, not a string
* require object context, which seems to fix the partial requirement in type and thus the type issue
* mistake
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* [SIEM] Fix Timeline registerProvider to be called only when it's needed
* cleanup
* add unit tests
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>