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

Update history to >=5.0 and to allow transaction retry #132600

Open
flash1293 opened this issue May 20, 2022 · 13 comments
Open

Update history to >=5.0 and to allow transaction retry #132600

flash1293 opened this issue May 20, 2022 · 13 comments
Labels
NeededFor:Security NeededFor:VisEditors old Used to help sort old issues on GH Projects which don't support the Created search term. Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)

Comments

@flash1293
Copy link
Contributor

In 5.0, the history package introduced a way to retry transactions in a block hook, allowing to do asynchronous blocks. As Kibana is currently using version 4.9, this isn't possible.

history should be upgraded to 5.x and the updated transaction object with the retry method should be passed through to consumers of .scoped history

@flash1293 flash1293 added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) labels May 20, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@legrego
Copy link
Member

legrego commented May 20, 2022

According to this comment, version 5.0 fixes a long outstanding bug with routing, which impacts a few management screens in Kibana, as well as Enterprise Search: #82440.

In other words, +1 to upgrading the history package 🙂

@pgayvallet
Copy link
Contributor

pgayvallet commented May 23, 2022

react-router is tightly coupled to history. I quickly tried to just bump history to 5.3.0, however without surprises, it causes type errors because of the incompatibilities of the newest version of history and the older version of history that react-router uses.

We're currently using react-router: ^5.2.0. but this version is based on history: ^4.9.0. We need to bump react-router to a later version that requires history: ^5.2.0, like the latest: "react-router": "^5.3.3"

Also, and this is the real issue here, the last version of the typings for react-router is 5.1.18 ( "@types/react-router": "^5.1.18",), which is still using history 4.x, so outdated types. We need to find a way to accept up-to-date types for react-router, else the upgrade will not be possible (react-router does not ship its types directly from the package and require a typedef)

@pgayvallet
Copy link
Contributor

pgayvallet commented May 23, 2022

So, I tried to bump history to 5.0.1, as it's the last version that doesn't introduce the generic removals from History and Location, however some types are still incompatible with the last version of react-router's type ("@types/react-router": "^5.1.18").

For example, MemoryRouterProps.initialEntries is still defined as H.LocationDescriptor[], which doesn't exist anymore in any history:^5.0.0 version.

Also, react-router 5.x is based on history v4.x. To avoid breaking changes between the two libraries, we would need to update react-router to v6+ at the same time...

@pgayvallet
Copy link
Contributor

Yet another thing: react-router-config, that we're using in some of our test packages, was never updated for react-router v6+, so we will likely need to check if the v5 version of this package can work with react-router v6, and if not, get rid of our usages of it.

@pgayvallet
Copy link
Contributor

pgayvallet commented May 23, 2022

So, after a few hours of investigation, the only possible approach here is to bump both history and react-router (at the same time) to their highest version:

  • history to 5.3.0+
  • react-router to 6.3.0+

In addition, react-router-config is no longer maintained nor compatible with react-router 6, as the features are now shipped directly into react-router core package, so we will need to get rid of it and adapt usages.

Also, the version 6 of react-router drops usage of all HOC components for their hook counterpart (e.g withRouter is removed), so we would need to adapt all our code accordingly.

There are also major changes in the latest version of react-router, such as the replacement of Switch to Routes, automatic usage of relative urls for nested routes, change of format for exact/non-exact routes, suppression of useHistory or useRouter in favor of higher-level hooks (which will be a pain for a lot of our test utils such as the kbn-test-jest-helpers package) and other fancy changes we'd need to perform.

Overall, this is a major library bump impacting all our routing code in every app we'd need to do here. We're talking weeks, maybe even months, of work.

There is a compatibility mode to supposedly help with such migration. May be worth digging a bit to see if that would potentially help us, but from my experience with compat mode from other libraries (hello angular), it usually just doesn't work with complex application using a lib's API to the extreme (And still require to adapt all imports of react-router in the codebase to use the compat package instead of the default one). EDIT: yea, will not work, the main package bump is performed at the end of the migration, so history would not be updated until we actually perform the full upgrade anyway.

I opened a draft PR to take a look at it, but that's only for investigation purposes, I'm not planning on working actually on it, given the amount of work it represents.

@afharo
Copy link
Member

afharo commented May 25, 2022

Just dropping a note from the react-router docs:

If you're using React Router, you should never import anything directly from the react-router package, but you should have everything you need in either react-router-dom or react-router-native. Both of those packages re-export everything from react-router.

In other words, we may need to upgrade/install react-router-dom for our use case.

@pgayvallet
Copy link
Contributor

In other words, we may need to upgrade/install react-router-dom for our use case.

Yea, sorry, by upgrading react-router to 6.x.0, I meant both react-router and react-router-dom.

@lukeelmers
Copy link
Member

This is blocking the VisEditors team in moving away from the deprecated onAppLeave, which is targeted for removal by 8.8.

@pgayvallet
Copy link
Contributor

which is targeted for removal by 8.8

Well... Which is currently targeted for removal by 8.8. If the recommended alternative (history.block with current history 4.x implementation) does not provide feature parity, we can't really remove it. We should update this deprecation notice, given the new info we have.

As much I as would love to resolve the problem by bumping those libs, as said, this is a cross-team multi week/month effort here. If supporting the new implementation of history.block / removing onAppLeave is the only outcome, I'm afraid we can't really justify the cost here, wdyt @lukeelmers?

@lukeelmers
Copy link
Member

I'm afraid we can't really justify the cost here, wdyt @lukeelmers?

Yep I tend to agree. It is up to us whether this should be blocking the vis editors team, and deferring the removal of onAppLeave (or just deciding not to deprecate it at all) is a perfectly valid option IMO.

Unless there is any other reason to make this upgrade besides "because we are supposed to remove onAppLeave", then it feels hard to justify knowing how large of an effort this would be.

@legrego
Copy link
Member

legrego commented Jun 20, 2022

Unless there is any other reason to make this upgrade besides "because we are supposed to remove onAppLeave", then it feels hard to justify knowing how large of an effort this would be.

Any other reason? 😉 We still have #82440, which impacts any app which uses path-based routing (e.g. /app/myApp/user%generated%portion/), with entities that contain certain special characters, such as %. In practice, this means that any path-based route with user-controlled input is potentially susceptible.

Having said that, it sounds like the level of effort still wouldn't be justified.

@yuliacech
Copy link
Contributor

yuliacech commented Sep 20, 2023

Any other reason? 😉 We still have #82440, which impacts any app which uses path-based routing (e.g. /app/myApp/user%generated%portion/), with entities that contain certain special characters, such as %. In practice, this means that any path-based route with user-controlled input is potentially susceptible.

We found a workaround for the user-generated input in the path: to use it only in a query param, for example /indices/${indexName} -> /indices/index_details?indexName=${indexName} (#166882)

yuliacech added a commit that referenced this issue Sep 22, 2023
## Summary
Fixes #166100

This PR adds a workaround fix for the new index details page when
opening for index names with special characters, for example
`test_index%`. Because of how encoding/decoding works, we can't use the
index name as a part of the url like `/indices/${indexName}` (see for
more details). Instead we have to pass the index name in a query
parameter like `/indices/index_details?indexName=${indexName}. The
downside of this workaround is that the url semantics doesn't reflect
that the index name is mandatory for the page to work. Once
#132600 is resolved, we should
revert this workaround and use the index name as a url segment again.

Note for reviewers: The jest tests for this fix are part of
#165705

### How to test
1. Add `xpack.index_management.dev.enableIndexDetailsPage: true` to the
file `config/kibana.dev.yml` to enable the new index details page
2. Navigate to Index Management and use the "create index" button 
3. Type a name with special characters, for example `test%`
4. Click the new index name in the list and check that the details page
and all tabs work
5. Also reload the page completely and check that the page still loads
correctly

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Alison Goryachev <alisonmllr20@gmail.com>
joemcelroy pushed a commit to joemcelroy/kibana that referenced this issue Sep 25, 2023
…166882)

## Summary
Fixes elastic#166100

This PR adds a workaround fix for the new index details page when
opening for index names with special characters, for example
`test_index%`. Because of how encoding/decoding works, we can't use the
index name as a part of the url like `/indices/${indexName}` (see for
more details). Instead we have to pass the index name in a query
parameter like `/indices/index_details?indexName=${indexName}. The
downside of this workaround is that the url semantics doesn't reflect
that the index name is mandatory for the page to work. Once
elastic#132600 is resolved, we should
revert this workaround and use the index name as a url segment again.

Note for reviewers: The jest tests for this fix are part of
elastic#165705

### How to test
1. Add `xpack.index_management.dev.enableIndexDetailsPage: true` to the
file `config/kibana.dev.yml` to enable the new index details page
2. Navigate to Index Management and use the "create index" button 
3. Type a name with special characters, for example `test%`
4. Click the new index name in the list and check that the details page
and all tabs work
5. Also reload the page completely and check that the page still loads
correctly

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Alison Goryachev <alisonmllr20@gmail.com>
@TinaHeiligers TinaHeiligers removed the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label Sep 19, 2024
@petrklapka petrklapka added the old Used to help sort old issues on GH Projects which don't support the Created search term. label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeededFor:Security NeededFor:VisEditors old Used to help sort old issues on GH Projects which don't support the Created search term. Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants