-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) # Backport This will backport the following commits from `main` to `8.x`: - [[Automatic Import] Add Error handling framework (#193577)](#193577) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Bharat Pasupula","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-25T14:24:01Z","message":"[Automatic Import] Add Error handling framework (#193577)\n\n## Release Note\r\n\r\nAdds error handling framework that provides error message with more\r\ncontext to user.\r\n\r\n## Summary\r\n\r\nRelates - [192916](https://github.com/elastic/kibana/issues/192916)\r\n\r\nThis PR adds an error handling framework.\r\n- Add Error classes for specific error scenarios.\r\n- If the error caught is of the predefined Error type the `message` and\r\n`errorCode` is sent back to UI from server.\r\n- The original error message is used to track telemetry and the\r\nerrorCode can be translated into a User visible error.\r\n- If there is any non-predefined error server still throws a\r\n`badRequest` with the error message.\r\n\r\nThis PR also adds/updates the graph images for different langgraphs\r\n\r\n## Screenshots for error messages\r\n<img width=\"690\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/bb848ce7-e474-4e4e-8d07-59b534c543ea\">\r\n\r\n<img width=\"691\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/fbf4cf46-9bbe-4c37-aaaa-0ede1cdcba7c\">\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"9fb6f5582220148820fb6b83880539f8df0b0841","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["enhancement","v9.0.0","release_note:feature","backport:prev-minor","Team:Security-Scalability","Feature:AutomaticImport"],"title":"[Automatic Import] Add Error handling framework","number":193577,"url":"https://github.com/elastic/kibana/pull/193577","mergeCommit":{"message":"[Automatic Import] Add Error handling framework (#193577)\n\n## Release Note\r\n\r\nAdds error handling framework that provides error message with more\r\ncontext to user.\r\n\r\n## Summary\r\n\r\nRelates - [192916](https://github.com/elastic/kibana/issues/192916)\r\n\r\nThis PR adds an error handling framework.\r\n- Add Error classes for specific error scenarios.\r\n- If the error caught is of the predefined Error type the `message` and\r\n`errorCode` is sent back to UI from server.\r\n- The original error message is used to track telemetry and the\r\nerrorCode can be translated into a User visible error.\r\n- If there is any non-predefined error server still throws a\r\n`badRequest` with the error message.\r\n\r\nThis PR also adds/updates the graph images for different langgraphs\r\n\r\n## Screenshots for error messages\r\n<img width=\"690\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/bb848ce7-e474-4e4e-8d07-59b534c543ea\">\r\n\r\n<img width=\"691\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/fbf4cf46-9bbe-4c37-aaaa-0ede1cdcba7c\">\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"9fb6f5582220148820fb6b83880539f8df0b0841"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193577","number":193577,"mergeCommit":{"message":"[Automatic Import] Add Error handling framework (#193577)\n\n## Release Note\r\n\r\nAdds error handling framework that provides error message with more\r\ncontext to user.\r\n\r\n## Summary\r\n\r\nRelates - [192916](https://github.com/elastic/kibana/issues/192916)\r\n\r\nThis PR adds an error handling framework.\r\n- Add Error classes for specific error scenarios.\r\n- If the error caught is of the predefined Error type the `message` and\r\n`errorCode` is sent back to UI from server.\r\n- The original error message is used to track telemetry and the\r\nerrorCode can be translated into a User visible error.\r\n- If there is any non-predefined error server still throws a\r\n`badRequest` with the error message.\r\n\r\nThis PR also adds/updates the graph images for different langgraphs\r\n\r\n## Screenshots for error messages\r\n<img width=\"690\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/bb848ce7-e474-4e4e-8d07-59b534c543ea\">\r\n\r\n<img width=\"691\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/fbf4cf46-9bbe-4c37-aaaa-0ede1cdcba7c\">\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"9fb6f5582220148820fb6b83880539f8df0b0841"}}]}] BACKPORT--> Co-authored-by: Bharat Pasupula <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
acd50da
commit a84d8cb
Showing
22 changed files
with
332 additions
and
20 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
Binary file modified
BIN
+6.25 KB
(110%)
x-pack/plugins/integration_assistant/docs/imgs/categorization_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-662 Bytes
(98%)
x-pack/plugins/integration_assistant/docs/imgs/ecs_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.56 KB
(100%)
x-pack/plugins/integration_assistant/docs/imgs/ecs_subgraph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+14.1 KB
(200%)
x-pack/plugins/integration_assistant/docs/imgs/log_detection_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+8.49 KB
(130%)
x-pack/plugins/integration_assistant/docs/imgs/related_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
17 changes: 17 additions & 0 deletions
17
x-pack/plugins/integration_assistant/server/lib/errors/index.ts
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 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { ErrorThatHandlesItsOwnResponse } from './types'; | ||
|
||
export function isErrorThatHandlesItsOwnResponse( | ||
e: ErrorThatHandlesItsOwnResponse | ||
): e is ErrorThatHandlesItsOwnResponse { | ||
return typeof (e as ErrorThatHandlesItsOwnResponse).sendResponse === 'function'; | ||
} | ||
|
||
export { RecursionLimitError } from './recursion_limit_error'; | ||
export { UnsupportedLogFormatError } from './unsupported_error'; |
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/integration_assistant/server/lib/errors/recursion_limit_error.ts
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,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { KibanaResponseFactory } from '@kbn/core/server'; | ||
import { ErrorThatHandlesItsOwnResponse } from './types'; | ||
|
||
export class RecursionLimitError extends Error implements ErrorThatHandlesItsOwnResponse { | ||
private readonly errorCode: string; | ||
|
||
constructor(message: string, errorCode: string) { | ||
super(message); | ||
this.errorCode = errorCode; | ||
} | ||
|
||
public sendResponse(res: KibanaResponseFactory) { | ||
return res.badRequest({ | ||
body: { message: this.message, attributes: { errorCode: this.errorCode } }, | ||
}); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
x-pack/plugins/integration_assistant/server/lib/errors/types.ts
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,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { KibanaResponseFactory, IKibanaResponse } from '@kbn/core/server'; | ||
|
||
export interface ErrorThatHandlesItsOwnResponse extends Error { | ||
sendResponse(res: KibanaResponseFactory): IKibanaResponse; | ||
} |
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/integration_assistant/server/lib/errors/unsupported_error.ts
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,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { KibanaResponseFactory } from '@kbn/core/server'; | ||
import { ErrorThatHandlesItsOwnResponse } from './types'; | ||
import { ErrorCode } from '../../../common/constants'; | ||
|
||
export class UnsupportedLogFormatError extends Error implements ErrorThatHandlesItsOwnResponse { | ||
private readonly errorCode: string = ErrorCode.UNSUPPORTED_LOG_SAMPLES_FORMAT; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-useless-constructor | ||
constructor(message: string) { | ||
super(message); | ||
} | ||
|
||
public sendResponse(res: KibanaResponseFactory) { | ||
return res.customError({ | ||
statusCode: 501, | ||
body: { message: this.message, attributes: { errorCode: this.errorCode } }, | ||
}); | ||
} | ||
} |
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
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.