-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ML] Moves shared code to @kbn/ml-error-utils
.
#155372
Conversation
Pinging @elastic/ml-ui (:ml) |
@@ -35,6 +35,7 @@ export interface MLResponseError { | |||
} | |||
|
|||
export interface ErrorMessage { | |||
query: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we have two different versions of ErrorMessage
in ML, this one is used in conjunction with isErrorMessage
and is used for extracting the message string from an error returned from the kibana server which contains a message
.
The other types which contain query
are created in client side code, where the query
is added to the error object for later use.
I think we should keep these separate and have an interface which extends ErrorMessage
to add the query
.
IMO this new interface shouldn't live in this file as these types are purely for describing errors returned from es or kibana.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll do some renaming to make them more distinct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming done in cf1b19a.
…nto ml-package-error-utils
Pinging @elastic/uptime (Team:uptime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @walterra |
PR #155372 moved our error utils to a package and also made a few small code changes, one of which added `isPopulatedObject` to the error object type guards. `isPopulatedObject` uses `Object.keys` under the hood which cannot be used to access the non-enumerable properties of an object, like Error's `message`. ![image](https://github.com/elastic/kibana/assets/22172091/6a0269df-ca2a-494a-9364-8f35f2b52388) This PR reverts all of these functions back to their original versions which had existed in ML for a while without issue. This was change had been causing error messages to not display correctly. ![image](https://github.com/elastic/kibana/assets/22172091/1862f069-1626-4ac3-8961-dca016b91956) vs ![image](https://github.com/elastic/kibana/assets/22172091/243143a5-0c8f-4365-a41d-7c1c09858ad8)
PR elastic#155372 moved our error utils to a package and also made a few small code changes, one of which added `isPopulatedObject` to the error object type guards. `isPopulatedObject` uses `Object.keys` under the hood which cannot be used to access the non-enumerable properties of an object, like Error's `message`. ![image](https://github.com/elastic/kibana/assets/22172091/6a0269df-ca2a-494a-9364-8f35f2b52388) This PR reverts all of these functions back to their original versions which had existed in ML for a while without issue. This was change had been causing error messages to not display correctly. ![image](https://github.com/elastic/kibana/assets/22172091/1862f069-1626-4ac3-8961-dca016b91956) vs ![image](https://github.com/elastic/kibana/assets/22172091/243143a5-0c8f-4365-a41d-7c1c09858ad8) (cherry picked from commit 8ca1789)
#159923) # Backport This will backport the following commits from `main` to `8.8`: - [[ML] Reverting use of isPopulatedObject in error utils (#159913)](#159913) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"James Gowdy","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-19T12:52:11Z","message":"[ML] Reverting use of isPopulatedObject in error utils (#159913)\n\nPR #155372 moved our error utils\r\nto a package and also made a few small code changes, one of which added\r\n`isPopulatedObject` to the error object type guards.\r\n`isPopulatedObject` uses `Object.keys` under the hood which cannot be\r\nused to access the non-enumerable properties of an object, like Error's\r\n`message`.\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/22172091/6a0269df-ca2a-494a-9364-8f35f2b52388)\r\n\r\nThis PR reverts all of these functions back to their original versions\r\nwhich had existed in ML for a while without issue.\r\n\r\nThis was change had been causing error messages to not display\r\ncorrectly.\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/22172091/1862f069-1626-4ac3-8961-dca016b91956)\r\n\r\nvs\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/22172091/243143a5-0c8f-4365-a41d-7c1c09858ad8)","sha":"8ca1789faa899f2e0a7abcf58fac50fa4d552af6","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","v8.9.0","v8.8.2"],"number":159913,"url":"https://github.com/elastic/kibana/pull/159913","mergeCommit":{"message":"[ML] Reverting use of isPopulatedObject in error utils (#159913)\n\nPR #155372 moved our error utils\r\nto a package and also made a few small code changes, one of which added\r\n`isPopulatedObject` to the error object type guards.\r\n`isPopulatedObject` uses `Object.keys` under the hood which cannot be\r\nused to access the non-enumerable properties of an object, like Error's\r\n`message`.\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/22172091/6a0269df-ca2a-494a-9364-8f35f2b52388)\r\n\r\nThis PR reverts all of these functions back to their original versions\r\nwhich had existed in ML for a while without issue.\r\n\r\nThis was change had been causing error messages to not display\r\ncorrectly.\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/22172091/1862f069-1626-4ac3-8961-dca016b91956)\r\n\r\nvs\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/22172091/243143a5-0c8f-4365-a41d-7c1c09858ad8)","sha":"8ca1789faa899f2e0a7abcf58fac50fa4d552af6"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159913","number":159913,"mergeCommit":{"message":"[ML] Reverting use of isPopulatedObject in error utils (#159913)\n\nPR #155372 moved our error utils\r\nto a package and also made a few small code changes, one of which added\r\n`isPopulatedObject` to the error object type guards.\r\n`isPopulatedObject` uses `Object.keys` under the hood which cannot be\r\nused to access the non-enumerable properties of an object, like Error's\r\n`message`.\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/22172091/6a0269df-ca2a-494a-9364-8f35f2b52388)\r\n\r\nThis PR reverts all of these functions back to their original versions\r\nwhich had existed in ML for a while without issue.\r\n\r\nThis was change had been causing error messages to not display\r\ncorrectly.\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/22172091/1862f069-1626-4ac3-8961-dca016b91956)\r\n\r\nvs\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/22172091/243143a5-0c8f-4365-a41d-7c1c09858ad8)","sha":"8ca1789faa899f2e0a7abcf58fac50fa4d552af6"}},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: James Gowdy <[email protected]>
Summary
Part of #136182.
x-pack/plugins/ml/common/util/errors
that was shared viax-pack/plugins/ml/public/shared.ts
to@kbn/ml-error-utils
.data_visualizer
andaiops
plugins now use that package instead of code duplication.Checklist