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

[RO] Incorrect Deletion of Webhook Actions in Kibana Rules #159204

Merged
merged 5 commits into from
Jun 12, 2023

Conversation

jcger
Copy link
Contributor

@jcger jcger commented Jun 7, 2023

Summary

Fixes #158167

The issue occurred because we were using a number called "index" as the React key prop. When we removed the first element, the second one took its place, but React still showed the removed element.

To fix this problem, we found a solution by using the uuid field that each action item has. We now generate it for each new action we create in the action form and use that as key

I was told to add @pmuellr as you might know if we are missing something 🙇

Test: why xpath selector?

I had to use the xpath selector to fix a problem we had. The problem was between two actions we set up. They look the same, but the body content is the only different (I've attached a screenshot for more details).

We use a third party component for these actions. This component doesn't have any "value" attribute and doesn't add anything besides the HTML text. I tried to find other useful details but couldn't find any.

The problem comes up when we try to delete one of the actions. To fix it, we needed to check if that component was missing. We already have tools that can look for missing components, but they don't work with the xpath selector. So, I added a new function that can do this. Now, we can use the xpath selector to look for missing components and fix the problem

See Screenshot

Tasks

@jcger jcger changed the title add uuid to new actions [RO] Delete actions Jun 7, 2023
@jcger jcger added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.9.0 release_note:fix labels Jun 7, 2023
@jcger jcger changed the title [RO] Delete actions [RO] Incorrect Deletion of Webhook Actions in Kibana Rules Jun 7, 2023
@jcger jcger requested a review from pmuellr June 7, 2023 14:06
@jcger jcger marked this pull request as ready for review June 7, 2023 14:06
@jcger jcger requested a review from a team as a code owner June 7, 2023 14:06
@elasticmachine
Copy link
Contributor

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

@gjelenc
Copy link

gjelenc commented Jun 9, 2023

Could this be released in v8.8.2 ?

@pmuellr
Copy link
Member

pmuellr commented Jun 9, 2023

Make sure that it's ok to generate the uuid

Yes, I believe that's fine. I think it's possible the uuid could be different when the rule is retrieved again - the idea is that it just provides uniqueness and therefore a key, but the value doesn't need to persist long-term with the action. @ersin-erdal is that correct?

Do we need to backport? Versions?
Could this be released in v8.8.2 ?

Yes, I think we should get this in 8.8.2 if possible.

@pmuellr pmuellr requested a review from ersin-erdal June 9, 2023 12:32
@ersin-erdal
Copy link
Contributor

ersin-erdal commented Jun 9, 2023

Make sure that it's ok to generate the uuid

Yes, I believe that's fine. I think it's possible the uuid could be different when the rule is retrieved again - the idea is that it just provides uniqueness and therefore a key, but the value doesn't need to persist long-term with the action. @ersin-erdal is that correct?

Do we need to backport? Versions?
Could this be released in v8.8.2 ?

Yes, I think we should get this in 8.8.2 if possible.

Yes i also think this is ok.
This is just for the uniqueness on UI.
create rule http request doesn't send it to BE, therefore BE generates another one for the action and sticks with it.
If you think that you may need this specific uuid later, must add it to http request as well.

Update request sends the uuid generated here to BE but that's also ok.

@pmuellr
Copy link
Member

pmuellr commented Jun 9, 2023

Update request sends the uuid generated here to BE but that's also ok.

Ya, the uuid is just used for uniqueness, interesting that it's being used by BE and FE but they are kinda independent! These feel kinda weird since they aren't "sticky" - you can replace them when updating the rule. But I also can't think of any particular reason why trying to keep them "sticky" between BE and FE would be useful, right now. Seems like we can make that happen in the future, if we want to ...

edit: apparently I was wrong, see two comments below from Ersin, so x-ed out my comment

Copy link
Member

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

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

LGTM

@ersin-erdal
Copy link
Contributor

Update request sends the uuid generated here to BE but that's also ok.

Ya, the uuid is just used for uniqueness, interesting that it's being used by BE and FE but they are kinda independent! These feel kinda weird since they aren't "sticky" - you can replace them when updating the rule. But I also can't think of any particular reason why trying to keep them "sticky" between BE and FE would be useful, right now. Seems like we can make that happen in the future, if we want to ...

We used uuid for summarised alerts. And as summary feature is action based, we need uuid to detect which action is still being throttled or which action is removed from a rule. As we replace the whole rule on update, we would lost the uuids if UI doesn't return them.

@jcger jcger requested a review from a team as a code owner June 9, 2023 16:22
@jcger jcger added the v8.8.0 label Jun 9, 2023
);

// check that the removed action is the right one
const doesExist = await find.existsByXpath(".//*[text()='myUniqueKey']");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't think of a better way to check that the right action is removed. Open to suggestions

Copy link
Member

Choose a reason for hiding this comment

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

In general, we try to use test subjects over xpath expressions where possible. In this case, the xpath way seems reasonable to me.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

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 +57.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
triggersActionsUi 85.4KB 85.4KB +1.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 413 417 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 497 501 +4
total +6

History

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

Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

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

LGTM

@jcger jcger merged commit 55bc8cf into elastic:main Jun 12, 2023
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 12, 2023
…59204)

## Summary

Fixes elastic#158167

The issue occurred because we were using a number called "index" as the
React key prop. When we removed the first element, the second one took
its place, but React still showed the removed element.

To fix this problem, we found a solution by using the uuid field that
each action item has. We now generate it for each new action we create
in the action form and use that as key

I was told to add @pmuellr as you might know if we are missing something
🙇

### Test: why xpath selector?

I had to use the xpath selector to fix a problem we had. The problem was
between two actions we set up. They look the same, but the body content
is the only different (I've attached a screenshot for more details).

We use a third party component for these actions. This component doesn't
have any "value" attribute and doesn't add anything besides the HTML
text. I tried to find other useful details but couldn't find any.

The problem comes up when we try to delete one of the actions. To fix
it, we needed to check if that component was missing. We already have
tools that can look for missing components, but they don't work with the
xpath selector. So, I added a new function that can do this. Now, we can
use the xpath selector to look for missing components and fix the
problem

<details>
<summary>See Screenshot</summary>
<img
src="https://github.com/elastic/kibana/assets/17549662/5447795d-0281-4847-aa85-76d0e5fdec3d"/>
</details>

```[tasklist]
- [x] Make sure that it's ok to generate the uuid
- [x] Test
- [x] Do we need to backport? Versions?
```

(cherry picked from commit 55bc8cf)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.8

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 12, 2023
…9204) (#159443)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[RO] Incorrect Deletion of Webhook Actions in Kibana Rules
(#159204)](#159204)

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

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

<!--BACKPORT [{"author":{"name":"Julian
Gernun","email":"17549662+jcger@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-06-12T08:19:20Z","message":"[RO]
Incorrect Deletion of Webhook Actions in Kibana Rules (#159204)\n\n##
Summary\r\n\r\nFixes #158167\r\n\r\nThe issue occurred because we were
using a number called \"index\" as the\r\nReact key prop. When we
removed the first element, the second one took\r\nits place, but React
still showed the removed element.\r\n\r\nTo fix this problem, we found a
solution by using the uuid field that\r\neach action item has. We now
generate it for each new action we create\r\nin the action form and use
that as key\r\n\r\nI was told to add @pmuellr as you might know if we
are missing something\r\n🙇\r\n\r\n### Test: why xpath selector?\r\n\r\nI
had to use the xpath selector to fix a problem we had. The problem
was\r\nbetween two actions we set up. They look the same, but the body
content\r\nis the only different (I've attached a screenshot for more
details).\r\n\r\nWe use a third party component for these actions. This
component doesn't\r\nhave any \"value\" attribute and doesn't add
anything besides the HTML\r\ntext. I tried to find other useful details
but couldn't find any.\r\n\r\nThe problem comes up when we try to delete
one of the actions. To fix\r\nit, we needed to check if that component
was missing. We already have\r\ntools that can look for missing
components, but they don't work with the\r\nxpath selector. So, I added
a new function that can do this. Now, we can\r\nuse the xpath selector
to look for missing components and fix the\r\nproblem\r\n
\r\n<details>\r\n<summary>See
Screenshot</summary>\r\n<img\r\nsrc=\"https://github.com/elastic/kibana/assets/17549662/5447795d-0281-4847-aa85-76d0e5fdec3d\"/>\r\n</details>\r\n\r\n```[tasklist]\r\n-
[x] Make sure that it's ok to generate the uuid\r\n- [x] Test\r\n- [x]
Do we need to backport?
Versions?\r\n```","sha":"55bc8cf567a437581d37e6e7d1380216667f34cd","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","v8.8.0","v8.9.0"],"number":159204,"url":"#159204
Incorrect Deletion of Webhook Actions in Kibana Rules (#159204)\n\n##
Summary\r\n\r\nFixes #158167\r\n\r\nThe issue occurred because we were
using a number called \"index\" as the\r\nReact key prop. When we
removed the first element, the second one took\r\nits place, but React
still showed the removed element.\r\n\r\nTo fix this problem, we found a
solution by using the uuid field that\r\neach action item has. We now
generate it for each new action we create\r\nin the action form and use
that as key\r\n\r\nI was told to add @pmuellr as you might know if we
are missing something\r\n🙇\r\n\r\n### Test: why xpath selector?\r\n\r\nI
had to use the xpath selector to fix a problem we had. The problem
was\r\nbetween two actions we set up. They look the same, but the body
content\r\nis the only different (I've attached a screenshot for more
details).\r\n\r\nWe use a third party component for these actions. This
component doesn't\r\nhave any \"value\" attribute and doesn't add
anything besides the HTML\r\ntext. I tried to find other useful details
but couldn't find any.\r\n\r\nThe problem comes up when we try to delete
one of the actions. To fix\r\nit, we needed to check if that component
was missing. We already have\r\ntools that can look for missing
components, but they don't work with the\r\nxpath selector. So, I added
a new function that can do this. Now, we can\r\nuse the xpath selector
to look for missing components and fix the\r\nproblem\r\n
\r\n<details>\r\n<summary>See
Screenshot</summary>\r\n<img\r\nsrc=\"https://github.com/elastic/kibana/assets/17549662/5447795d-0281-4847-aa85-76d0e5fdec3d\"/>\r\n</details>\r\n\r\n```[tasklist]\r\n-
[x] Make sure that it's ok to generate the uuid\r\n- [x] Test\r\n- [x]
Do we need to backport?
Versions?\r\n```","sha":"55bc8cf567a437581d37e6e7d1380216667f34cd"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"#159204
Incorrect Deletion of Webhook Actions in Kibana Rules (#159204)\n\n##
Summary\r\n\r\nFixes #158167\r\n\r\nThe issue occurred because we were
using a number called \"index\" as the\r\nReact key prop. When we
removed the first element, the second one took\r\nits place, but React
still showed the removed element.\r\n\r\nTo fix this problem, we found a
solution by using the uuid field that\r\neach action item has. We now
generate it for each new action we create\r\nin the action form and use
that as key\r\n\r\nI was told to add @pmuellr as you might know if we
are missing something\r\n🙇\r\n\r\n### Test: why xpath selector?\r\n\r\nI
had to use the xpath selector to fix a problem we had. The problem
was\r\nbetween two actions we set up. They look the same, but the body
content\r\nis the only different (I've attached a screenshot for more
details).\r\n\r\nWe use a third party component for these actions. This
component doesn't\r\nhave any \"value\" attribute and doesn't add
anything besides the HTML\r\ntext. I tried to find other useful details
but couldn't find any.\r\n\r\nThe problem comes up when we try to delete
one of the actions. To fix\r\nit, we needed to check if that component
was missing. We already have\r\ntools that can look for missing
components, but they don't work with the\r\nxpath selector. So, I added
a new function that can do this. Now, we can\r\nuse the xpath selector
to look for missing components and fix the\r\nproblem\r\n
\r\n<details>\r\n<summary>See
Screenshot</summary>\r\n<img\r\nsrc=\"https://github.com/elastic/kibana/assets/17549662/5447795d-0281-4847-aa85-76d0e5fdec3d\"/>\r\n</details>\r\n\r\n```[tasklist]\r\n-
[x] Make sure that it's ok to generate the uuid\r\n- [x] Test\r\n- [x]
Do we need to backport?
Versions?\r\n```","sha":"55bc8cf567a437581d37e6e7d1380216667f34cd"}}]}]
BACKPORT-->

Co-authored-by: Julian Gernun <17549662+jcger@users.noreply.github.com>
saarikabhasi pushed a commit to saarikabhasi/kibana that referenced this pull request Jun 14, 2023
…59204)

## Summary

Fixes elastic#158167

The issue occurred because we were using a number called "index" as the
React key prop. When we removed the first element, the second one took
its place, but React still showed the removed element.

To fix this problem, we found a solution by using the uuid field that
each action item has. We now generate it for each new action we create
in the action form and use that as key

I was told to add @pmuellr as you might know if we are missing something
🙇

### Test: why xpath selector?

I had to use the xpath selector to fix a problem we had. The problem was
between two actions we set up. They look the same, but the body content
is the only different (I've attached a screenshot for more details).

We use a third party component for these actions. This component doesn't
have any "value" attribute and doesn't add anything besides the HTML
text. I tried to find other useful details but couldn't find any.

The problem comes up when we try to delete one of the actions. To fix
it, we needed to check if that component was missing. We already have
tools that can look for missing components, but they don't work with the
xpath selector. So, I added a new function that can do this. Now, we can
use the xpath selector to look for missing components and fix the
problem
 
<details>
<summary>See Screenshot</summary>
<img
src="https://github.com/elastic/kibana/assets/17549662/5447795d-0281-4847-aa85-76d0e5fdec3d"/>
</details>

```[tasklist]
- [x] Make sure that it's ok to generate the uuid
- [x] Test
- [x] Do we need to backport? Versions?
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:fix Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.8.0 v8.8.2 v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Response Ops] [Rules] Removing Webhook A actually deletes Webhook B while creating rule
8 participants