-
Notifications
You must be signed in to change notification settings - Fork 920
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
[Discover][Bug] Migrate global state from legacy URL #6780
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fix: | ||
- [Discover][Bug] Migrate global state from legacy URL ([#6780](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6780)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,7 +133,9 @@ | |
indexPattern: index, | ||
}, | ||
}; | ||
const _g = getStateFromOsdUrl<any>('_g', oldPath); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this path only entered if the url uses url fragments? I ask because it looks like Also, does your comment about ftr tests address the lack of test coverage here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My current understanding is that the legacy urls are all like http://localhost:5601/app/discover#/, there should be no issue with parsing and handling _g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add the unit test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should also define the type here like the previous LegacyDiscoverState from line #114. From my memory, i think global state should include time filter and global filter, and then we can do something like the previous code:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is beneficial to define the type for globalState to ensure type safety and clarity. However, since the globalState can include various parameters (time, filters, freshInterval and etc), we should ensure that the type definition encompasses all possible states. So I put |
||
|
||
path = setStateToOsdUrl('_g', _g, { useHash: false }, path); | ||
path = setStateToOsdUrl('_a', _a, { useHash: false }, path); | ||
path = setStateToOsdUrl('_q', _q, { useHash: false }, path); | ||
|
||
|
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.
line #136 should move before line #116 and then line #116 should also include testing if global state is null or not. We only
return path
if both app state and global state are null. So we do notreturn path
if app state is null and we miss the states from global state.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.
I think we would like to proceed with the migration regardless of the presence of the global state (
_g
).First of all, checking for both appState and globalState together and returning the path if either is null could miss valid migrations.
Here are some 2.9 urls with/withoug
_g
:_g
, index pattern has a timestampIf we remove
_g
from the urlthen refresh the url, it will turn to
, where a default
_g
is added_g
: index pattern without time series dataBy default, for idx without time series, there is a default
_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))
but if remove_g
from the urlit will turn to
without adding back
_g
with default state.Therefore, it is possible for a URL to be without global state, either by mistake or non-time-series idx and still require proper migration.
Second, if the globalState is null (_g=!n), migration can still proceed. Just like the previous example, it will either add a default one, which is the same as 2.9 experience.
Therefore, it is more robust if we don't check global state in the migration function and just let opensearch_dashboards_utils handles the logic.