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

[Cases] Fix bug in cases bulk action in the alerts table #160526

Merged
merged 1 commit into from Jun 26, 2023

Conversation

cnasikas
Copy link
Member

@cnasikas cnasikas commented Jun 26, 2023

Summary

In 8.8 we move the logic of the cases action from solutions to the alerts table. A bug was introduced when you try to attach an alert to a new case through the cases modal.

Before

Screen.Recording.2023-06-26.at.5.26.32.PM.mov

Error in console

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')
    at getAttachments (use_bulk_actions.ts:100:1)
    at use_cases_add_to_existing_case_modal.tsx:52:1
    at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1)
    at all_cases_selector_modal.tsx:36:1
    at all_cases_list.tsx:208:1
    at table_filters.tsx:128:1
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)

After

Screen.Recording.2023-06-26.at.5.25.41.PM.mov

Checklist

Delete any items that are not applicable to this PR.

For maintainers

Release notes

Fix a bug in the alerts table where you cannot create a new case when attaching alerts to a case from the cases modal

@cnasikas cnasikas self-assigned this Jun 26, 2023
@cnasikas cnasikas added bug Fixes for quality problems that affect the customer experience Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Jun 26, 2023
@cnasikas cnasikas marked this pull request as ready for review June 26, 2023 14:31
@cnasikas cnasikas requested a review from a team as a code owner June 26, 2023 14:31
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops-cases (Feature:Cases)

Copy link
Contributor

@adcoelho adcoelho left a comment

Choose a reason for hiding this comment

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

Tested and works fine 👍

@@ -146,6 +146,10 @@ export const useBulkAddToCaseActions = ({
onClick: (alerts?: TimelineItem[]) => {
selectCaseModal.open({
getAttachments: ({ theCase }) => {
if (theCase == null) {
return alerts ? casesService?.helpers.groupAlertsByRule(alerts) ?? [] : [];
Copy link
Contributor

Choose a reason for hiding this comment

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

can alerts actually be missing? If this is triggered via the bulk actions it shouldn't ever, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't remember why but I followed the pattern used in the other action. Maybe there is a reason. I agree with you. It shouldn't be undefined.

@@ -124,6 +126,55 @@ describe('bulk action hooks', () => {
expect(openExistingCase).toHaveBeenCalled();
});

it('should open the flyout from the case modal', async () => {
Copy link
Contributor

@adcoelho adcoelho Jun 26, 2023

Choose a reason for hiding this comment

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

An e2e test for this would also be nice if there is time. Looked a bit for them but dunno if there even are any regarding bulk actions in the alerts table.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we have. Do you mind if we do it on another PR? I have this issue to track it #160240.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
triggersActionsUi 1.4MB 1.4MB +100.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 14 16 +2
securitySolution 416 420 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 15 17 +2
securitySolution 497 501 +4
total +6

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

cc @cnasikas

@cnasikas cnasikas merged commit df21ba0 into elastic:main Jun 26, 2023
37 checks passed
@cnasikas cnasikas deleted the fix_cases_bulk_actions branch June 26, 2023 15:32
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 26, 2023
)

## Summary

In 8.8 we move the logic of the cases action from solutions to the
alerts table. A bug was introduced when you try to attach an alert to a
new case through the cases modal.

Before

https://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6

Error in `console`

```
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')
    at getAttachments (use_bulk_actions.ts:100:1)
    at use_cases_add_to_existing_case_modal.tsx:52:1
    at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1)
    at all_cases_selector_modal.tsx:36:1
    at all_cases_list.tsx:208:1
    at table_filters.tsx:128:1
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)
```

After

https://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624

### Checklist

Delete any items that are not applicable to this PR.

- [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

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

## Release notes
Fix a bug in the alerts table where you cannot create a new case when
attaching alerts to a case from the cases modal

(cherry picked from commit df21ba0)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 26, 2023
)

## Summary

In 8.8 we move the logic of the cases action from solutions to the
alerts table. A bug was introduced when you try to attach an alert to a
new case through the cases modal.

Before

https://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6

Error in `console`

```
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')
    at getAttachments (use_bulk_actions.ts:100:1)
    at use_cases_add_to_existing_case_modal.tsx:52:1
    at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1)
    at all_cases_selector_modal.tsx:36:1
    at all_cases_list.tsx:208:1
    at table_filters.tsx:128:1
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)
```

After

https://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624

### Checklist

Delete any items that are not applicable to this PR.

- [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

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

## Release notes
Fix a bug in the alerts table where you cannot create a new case when
attaching alerts to a case from the cases modal

(cherry picked from commit df21ba0)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.8
8.9

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 26, 2023
…) (#160542)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Cases] Fix bug in cases bulk action in the alerts table
(#160526)](#160526)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Christos
Nasikas","email":"christos.nasikas@elastic.co"},"sourceCommit":{"committedDate":"2023-06-26T15:32:29Z","message":"[Cases]
Fix bug in cases bulk action in the alerts table (#160526)\n\n##
Summary\n\nIn 8.8 we move the logic of the cases action from solutions
to the\nalerts table. A bug was introduced when you try to attach an
alert to a\nnew case through the cases
modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError
in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read
properties of undefined (reading 'id')\n at getAttachments
(use_bulk_actions.ts:100:1)\n at
use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick
(use_cases_add_to_existing_case_modal.tsx:107:1)\n at
all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at
table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback
(react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev
(react-dom.development.js:3994:1)\n at invokeGuardedCallback
(react-dom.development.js:4056:1)\n at
invokeGuardedCallbackAndCatchFirstError
(react-dom.development.js:4070:1)\n```\n\nAfter
\n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n###
Checklist\n\nDelete any items that are not applicable to this PR.\n\n-
[x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n### For
maintainers\n\n- [x] This was checked for breaking API changes and was
[labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n##
Release notes\nFix a bug in the alerts table where you cannot create a
new case when\nattaching alerts to a case from the cases
modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:ResponseOps","Feature:Cases","v8.9.0","v8.8.2","v8.10.0"],"number":160526,"url":"#160526
Fix bug in cases bulk action in the alerts table (#160526)\n\n##
Summary\n\nIn 8.8 we move the logic of the cases action from solutions
to the\nalerts table. A bug was introduced when you try to attach an
alert to a\nnew case through the cases
modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError
in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read
properties of undefined (reading 'id')\n at getAttachments
(use_bulk_actions.ts:100:1)\n at
use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick
(use_cases_add_to_existing_case_modal.tsx:107:1)\n at
all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at
table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback
(react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev
(react-dom.development.js:3994:1)\n at invokeGuardedCallback
(react-dom.development.js:4056:1)\n at
invokeGuardedCallbackAndCatchFirstError
(react-dom.development.js:4070:1)\n```\n\nAfter
\n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n###
Checklist\n\nDelete any items that are not applicable to this PR.\n\n-
[x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n### For
maintainers\n\n- [x] This was checked for breaking API changes and was
[labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n##
Release notes\nFix a bug in the alerts table where you cannot create a
new case when\nattaching alerts to a case from the cases
modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c"}},"sourceBranch":"main","suggestedTargetBranches":["8.9","8.8"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"#160526
Fix bug in cases bulk action in the alerts table (#160526)\n\n##
Summary\n\nIn 8.8 we move the logic of the cases action from solutions
to the\nalerts table. A bug was introduced when you try to attach an
alert to a\nnew case through the cases
modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError
in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read
properties of undefined (reading 'id')\n at getAttachments
(use_bulk_actions.ts:100:1)\n at
use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick
(use_cases_add_to_existing_case_modal.tsx:107:1)\n at
all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at
table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback
(react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev
(react-dom.development.js:3994:1)\n at invokeGuardedCallback
(react-dom.development.js:4056:1)\n at
invokeGuardedCallbackAndCatchFirstError
(react-dom.development.js:4070:1)\n```\n\nAfter
\n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n###
Checklist\n\nDelete any items that are not applicable to this PR.\n\n-
[x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n### For
maintainers\n\n- [x] This was checked for breaking API changes and was
[labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n##
Release notes\nFix a bug in the alerts table where you cannot create a
new case when\nattaching alerts to a case from the cases
modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c"}}]}] BACKPORT-->

Co-authored-by: Christos Nasikas <christos.nasikas@elastic.co>
kibanamachine added a commit that referenced this pull request Jun 26, 2023
…) (#160543)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Cases] Fix bug in cases bulk action in the alerts table
(#160526)](#160526)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Christos
Nasikas","email":"christos.nasikas@elastic.co"},"sourceCommit":{"committedDate":"2023-06-26T15:32:29Z","message":"[Cases]
Fix bug in cases bulk action in the alerts table (#160526)\n\n##
Summary\n\nIn 8.8 we move the logic of the cases action from solutions
to the\nalerts table. A bug was introduced when you try to attach an
alert to a\nnew case through the cases
modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError
in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read
properties of undefined (reading 'id')\n at getAttachments
(use_bulk_actions.ts:100:1)\n at
use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick
(use_cases_add_to_existing_case_modal.tsx:107:1)\n at
all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at
table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback
(react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev
(react-dom.development.js:3994:1)\n at invokeGuardedCallback
(react-dom.development.js:4056:1)\n at
invokeGuardedCallbackAndCatchFirstError
(react-dom.development.js:4070:1)\n```\n\nAfter
\n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n###
Checklist\n\nDelete any items that are not applicable to this PR.\n\n-
[x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n### For
maintainers\n\n- [x] This was checked for breaking API changes and was
[labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n##
Release notes\nFix a bug in the alerts table where you cannot create a
new case when\nattaching alerts to a case from the cases
modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:ResponseOps","Feature:Cases","v8.9.0","v8.8.2","v8.10.0"],"number":160526,"url":"#160526
Fix bug in cases bulk action in the alerts table (#160526)\n\n##
Summary\n\nIn 8.8 we move the logic of the cases action from solutions
to the\nalerts table. A bug was introduced when you try to attach an
alert to a\nnew case through the cases
modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError
in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read
properties of undefined (reading 'id')\n at getAttachments
(use_bulk_actions.ts:100:1)\n at
use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick
(use_cases_add_to_existing_case_modal.tsx:107:1)\n at
all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at
table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback
(react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev
(react-dom.development.js:3994:1)\n at invokeGuardedCallback
(react-dom.development.js:4056:1)\n at
invokeGuardedCallbackAndCatchFirstError
(react-dom.development.js:4070:1)\n```\n\nAfter
\n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n###
Checklist\n\nDelete any items that are not applicable to this PR.\n\n-
[x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n### For
maintainers\n\n- [x] This was checked for breaking API changes and was
[labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n##
Release notes\nFix a bug in the alerts table where you cannot create a
new case when\nattaching alerts to a case from the cases
modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c"}},"sourceBranch":"main","suggestedTargetBranches":["8.9","8.8"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"#160526
Fix bug in cases bulk action in the alerts table (#160526)\n\n##
Summary\n\nIn 8.8 we move the logic of the cases action from solutions
to the\nalerts table. A bug was introduced when you try to attach an
alert to a\nnew case through the cases
modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError
in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read
properties of undefined (reading 'id')\n at getAttachments
(use_bulk_actions.ts:100:1)\n at
use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick
(use_cases_add_to_existing_case_modal.tsx:107:1)\n at
all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at
table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback
(react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev
(react-dom.development.js:3994:1)\n at invokeGuardedCallback
(react-dom.development.js:4056:1)\n at
invokeGuardedCallbackAndCatchFirstError
(react-dom.development.js:4070:1)\n```\n\nAfter
\n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n###
Checklist\n\nDelete any items that are not applicable to this PR.\n\n-
[x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n### For
maintainers\n\n- [x] This was checked for breaking API changes and was
[labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n##
Release notes\nFix a bug in the alerts table where you cannot create a
new case when\nattaching alerts to a case from the cases
modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c"}}]}] BACKPORT-->

Co-authored-by: Christos Nasikas <christos.nasikas@elastic.co>
@mistic
Copy link
Member

mistic commented Jun 29, 2023

This PR didn't make it into the latest build candidate of v8.8.2. Updating the labels.

@mistic mistic removed the v8.8.2 label Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Cases Cases feature release_note:fix Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.9.0 v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants