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

[EDR Workflows] Proper undefined routeState handling #181432

Merged

Conversation

szwarckonrad
Copy link
Contributor

@szwarckonrad szwarckonrad commented Apr 23, 2024

#181261

Check if routeState is defined before accessing it's properties in useCallback dependency list.

With changes:

Screen.Recording.2024-04-23.at.14.22.00.mov

Cypress tests when no undefined check is performed (application throws):
Screenshot 2024-04-23 at 14 46 37

@szwarckonrad szwarckonrad self-assigned this Apr 23, 2024
@szwarckonrad szwarckonrad added release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.14.0 v8.15.0 labels Apr 23, 2024
@szwarckonrad szwarckonrad changed the title [EDR Workflows] proper undefined route state handling [EDR Workflows] Proper undefined routeState handling Apr 23, 2024
@szwarckonrad szwarckonrad marked this pull request as ready for review April 23, 2024 13:04
@szwarckonrad szwarckonrad requested a review from a team as a code owner April 23, 2024 13:04
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-defend-workflows (Team:Defend Workflows)

@szwarckonrad
Copy link
Contributor Author

/ci

@@ -457,7 +457,7 @@ export const PolicyTabs = React.memo(() => {
cancelUnsavedChangesModal,
history,
policyId,
routeState.backLink,
routeState?.backLink,
Copy link
Member

Choose a reason for hiding this comment

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

This is the only change that fixes the issue. Right? I'm not sure what the nextTabId is needed for.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's only additional testing: nextTabId is in the artifact_page.ts fixture which is used to click through the artifact tabs on Policy Details page. so with nextTabId an additional click to the neighbour tab is added, to cover this situation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@gergoabraham gergoabraham left a comment

Choose a reason for hiding this comment

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

looks great, couldn't break it! 🚀 thanks for extending the test cases!

@szwarckonrad
Copy link
Contributor Author

/ci

@szwarckonrad szwarckonrad enabled auto-merge (squash) April 24, 2024 07:46
@szwarckonrad szwarckonrad merged commit 800289c into elastic:main Apr 24, 2024
35 checks passed
@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
securitySolution 14.6MB 14.6MB +15.0B

History

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

cc @szwarckonrad

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 24, 2024
elastic#181261

Check if `routeState` is defined before accessing it's properties in
`useCallback` dependency list.

With changes:

https://github.com/elastic/kibana/assets/29123534/4561c5d6-e354-4e0b-ac8a-dd231a26d722

Cypress tests when no undefined check is performed (application throws):
![Screenshot 2024-04-23 at 14 46
37](https://github.com/elastic/kibana/assets/29123534/ed7817dc-f11c-4f5e-bdf3-c6ee9f4c8ea6)

(cherry picked from commit 800289c)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.14

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 Apr 24, 2024
…#181529)

# Backport

This will backport the following commits from `main` to `8.14`:
- [[EDR Workflows] Proper undefined routeState handling
(#181432)](#181432)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Konrad
Szwarc","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-04-24T08:59:00Z","message":"[EDR
Workflows] Proper undefined routeState handling
(#181432)\n\nhttps://github.com//issues/181261\r\n\r\nCheck
if `routeState` is defined before accessing it's properties
in\r\n`useCallback` dependency list.\r\n\r\nWith
changes:\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/29123534/4561c5d6-e354-4e0b-ac8a-dd231a26d722\r\n\r\nCypress
tests when no undefined check is performed (application
throws):\r\n![Screenshot 2024-04-23 at 14
46\r\n37](https://github.com/elastic/kibana/assets/29123534/ed7817dc-f11c-4f5e-bdf3-c6ee9f4c8ea6)","sha":"800289c506aeceb7e1dffa650481d7e10dc5e70c","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Defend
Workflows","v8.14.0","v8.15.0"],"title":"[EDR Workflows] Proper
undefined routeState
handling","number":181432,"url":"https://github.com/elastic/kibana/pull/181432","mergeCommit":{"message":"[EDR
Workflows] Proper undefined routeState handling
(#181432)\n\nhttps://github.com//issues/181261\r\n\r\nCheck
if `routeState` is defined before accessing it's properties
in\r\n`useCallback` dependency list.\r\n\r\nWith
changes:\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/29123534/4561c5d6-e354-4e0b-ac8a-dd231a26d722\r\n\r\nCypress
tests when no undefined check is performed (application
throws):\r\n![Screenshot 2024-04-23 at 14
46\r\n37](https://github.com/elastic/kibana/assets/29123534/ed7817dc-f11c-4f5e-bdf3-c6ee9f4c8ea6)","sha":"800289c506aeceb7e1dffa650481d7e10dc5e70c"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/181432","number":181432,"mergeCommit":{"message":"[EDR
Workflows] Proper undefined routeState handling
(#181432)\n\nhttps://github.com//issues/181261\r\n\r\nCheck
if `routeState` is defined before accessing it's properties
in\r\n`useCallback` dependency list.\r\n\r\nWith
changes:\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/29123534/4561c5d6-e354-4e0b-ac8a-dd231a26d722\r\n\r\nCypress
tests when no undefined check is performed (application
throws):\r\n![Screenshot 2024-04-23 at 14
46\r\n37](https://github.com/elastic/kibana/assets/29123534/ed7817dc-f11c-4f5e-bdf3-c6ee9f4c8ea6)","sha":"800289c506aeceb7e1dffa650481d7e10dc5e70c"}}]}]
BACKPORT-->

Co-authored-by: Konrad Szwarc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.14.0 v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants