-
Notifications
You must be signed in to change notification settings - Fork 8k
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
[Security Solution] Update cache invalidation logic to handle error responses #146271
Conversation
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
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.
Tested locally and works as expected now.
Left a question about moving types on which I would like your opinion, but otherwise LGTM 👍
@@ -206,14 +206,22 @@ export interface BulkActionAggregatedError { | |||
rules: Array<{ id: string; name?: string }>; | |||
} | |||
|
|||
export interface BulkActionAttributes { |
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.
Thanks for adding these types and discriminating between successful and error responses 👍
Only thing: I also added these types for the bulk edit response while working on the skipped
rules PR. Do you think it makes sense to move them to the /common
folder and then import them to both server and public?
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.
@jpdjere Yes, if the types are the same on the front end and server side, it makes sense to move them to the common folder. Ideally, we should put there a runtime io-ts schema, which could be used for response validation, and derive the type from it.
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.
Allright, if we get merged this before than my PR I can update it on my side and refactor.
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.
Allright, if we get merged this before than my PR I can update it on my side and refactor.
Yes, as this one targets 8.6, it would be safer to do refactoring in the main
. Thank you, @jpdjere 👍
2a53e57
to
79909b7
Compare
💚 Build Succeeded
Metrics [docs]Async chunks
Unknown metric groupsESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @xcrzx |
…esponses (#146271) **Resolves: #146277 ## Summary Previously, we invalidated the rules table cache only after successful server-side state mutations. So when an action like bulk edit was successfully updating some rules and failing for others, the table continued showing outdated results. This PR moves the cache invalidation from the `onSuccess` handlers to the `onSettled` handlers to prevent showing partially stale data after failed updates. (cherry picked from commit e9bc603)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
…rror responses (#146271) (#146380) # Backport This will backport the following commits from `main` to `8.6`: - [[Security Solution] Update cache invalidation logic to handle error responses (#146271)](#146271) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Dmitrii Shevchenko","email":"dmitrii.shevchenko@elastic.co"},"sourceCommit":{"committedDate":"2022-11-28T11:50:40Z","message":"[Security Solution] Update cache invalidation logic to handle error responses (#146271)\n\n**Resolves: #146277 Summary\r\n\r\nPreviously, we invalidated the rules table cache only after successful\r\nserver-side state mutations. So when an action like bulk edit was\r\nsuccessfully updating some rules and failing for others, the table\r\ncontinued showing outdated results.\r\n\r\nThis PR moves the cache invalidation from the `onSuccess` handlers to\r\nthe `onSettled` handlers to prevent showing partially stale data after\r\nfailed updates.","sha":"e9bc60355858c82fe39676622004f8e9cdfa61a2","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","impact:low","Team:Detections and Resp","Team: SecuritySolution","auto-backport","Feature:Rule Management","Team:Detection Rules","v8.6.0","v8.7.0"],"number":146271,"url":"#146271 Solution] Update cache invalidation logic to handle error responses (#146271)\n\n**Resolves: #146277 Summary\r\n\r\nPreviously, we invalidated the rules table cache only after successful\r\nserver-side state mutations. So when an action like bulk edit was\r\nsuccessfully updating some rules and failing for others, the table\r\ncontinued showing outdated results.\r\n\r\nThis PR moves the cache invalidation from the `onSuccess` handlers to\r\nthe `onSettled` handlers to prevent showing partially stale data after\r\nfailed updates.","sha":"e9bc60355858c82fe39676622004f8e9cdfa61a2"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"#146271 Solution] Update cache invalidation logic to handle error responses (#146271)\n\n**Resolves: #146277 Summary\r\n\r\nPreviously, we invalidated the rules table cache only after successful\r\nserver-side state mutations. So when an action like bulk edit was\r\nsuccessfully updating some rules and failing for others, the table\r\ncontinued showing outdated results.\r\n\r\nThis PR moves the cache invalidation from the `onSuccess` handlers to\r\nthe `onSettled` handlers to prevent showing partially stale data after\r\nfailed updates.","sha":"e9bc60355858c82fe39676622004f8e9cdfa61a2"}}]}] BACKPORT--> Co-authored-by: Dmitrii Shevchenko <dmitrii.shevchenko@elastic.co>
Resolves: #146277
Summary
Previously, we invalidated the rules table cache only after successful server-side state mutations. So when an action like bulk edit was successfully updating some rules and failing for others, the table continued showing outdated results.
This PR moves the cache invalidation from the
onSuccess
handlers to theonSettled
handlers to prevent showing partially stale data after failed updates.