opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.68k stars 884 forks source link

[BUG] Filters in URL of saved searches are lost while page loading #7677

Open jonashellmann opened 2 months ago

jonashellmann commented 2 months ago

Describe the bug

When I want to open a saved search and add another filter to this saved search, this was possible by adding this information inside the URL. This worked with OpenSearch Dashboards 2.9 and prior. When loading OpenSearch Dashboards with such an URL for the first time in a browser tab, this filter information will get lost. The behaviour is different (and working) if you enter the URL into a browser tab where the Discover tab of OpenSearch Dashboards is already opened.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://playground.opensearch.org/app/data-explorer/discover
  2. Open any of the saved searches via the Open button in the top right corner
  3. Add any filter to the saved search, e.g. the filter OriginCountry is US for the saved search [Flights] Flight Log
  4. Either copy the link from the address bar or generate a link via the Share button in the top right corner with the Snapshot option activated.
  5. Paste the link into a new tab and load the page.

Expected behavior Since the filter is part of the copied or generated URL in the _q URL parameter the filter should be applied to the saved search when opened in a new browser tab. However, after having the filter actually visible for a very short time, it disappears and the URL doesn't contain this specific part in the _q URL parameter anymore. If you paste the same link from before into this browser tab where OpenSearch Dashboards is already loaded, the filter is applied and will not get removed so there must be some issue with the initial page loading.

OpenSearch Version 2.16

Dashboards Version 2.16

Plugins

Query Workbench Reporting Alerting Anomaly Detection Maps Security Analytics Search Relevance Machine Learning

Host/Environment (please complete the following information):

Additional context

jonashellmann commented 2 months ago

From my understanding, this should‘ve been resolved by PR #5206. However, I still can reproduce the problem, at least with saved searches. Similar issues, that have been closed, are #5248 and #5179.

shobull commented 2 months ago

I'm having the same experience as @jonashellmann ⬆️ on version 2.13.0. Filters are lost when I use "Share PERMALINK" or just copy-paste URL to different tab. I'm seeing this error notification: image with detail:

throwUnableToRestoreUrlError@https://<HOSTNAME>/_dashboards/<ID>/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:120289
retrieveState@https://<HOSTNAME>/_dashboards/<ID>/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:120559
decodeState@https://<HOSTNAME>/_dashboards/<ID>/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:121652
getStatesFromOsdUrl/<@https://<HOSTNAME>/_dashboards/<ID>/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:124726
getStatesFromOsdUrl@https://<HOSTNAME>/_dashboards/<ID>/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:124680
getStateFromOsdUrl@https://<HOSTNAME>/_dashboards/<ID>/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:124889
get@https://<HOSTNAME>/_dashboards/<ID>/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:131972
connectStorageToQueryState@https://<HOSTNAME>/_dashboards/<ID>/bundles/plugin/data/data.plugin.js:1:120613
TopNav@https://<HOSTNAME>/_dashboards/<ID>/bundles/plugin/discover/discover.chunk.4.js:1:40066
$i@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:57931
gs@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:104170
uc@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:96720
sc@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:96643
Qs@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:93673
Vo/<@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45315
__osdSharedDeps__</t.unstable_runWithPriority@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:443:3844
Xo@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45024
Vo@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45262
Yo@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45195
$s@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:90458
enqueueSetState@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:48980
__osdSharedDeps__</v.prototype.setState@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:419:1297
t/n.unlisten<@https://<HOSTNAME>/_dashboards/<ID>/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:349:230827
setupHistoryListener/unlisten</<@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:15:115188
setupHistoryListener/unlisten<@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:15:115161
e@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:6:161284
notifyListeners/<@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:6:161514
notifyListeners@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:6:161484
p@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:6:163015
w/<@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:6:163236
confirmTransitionTo@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:6:161224
w@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:6:163191
g@https://<HOSTNAME>/_dashboards/<ID>/bundles/core/core.entry.js:6:163096
ananzh commented 2 months ago

@shobull Thanks for the feedbacks and report. I think yours is a bit different. The error is in the opensearchDashboardsUtils.plugin.js file. This suggests that there's an issue with restoring a URL state. Could you try:

See if the error is gone. Let us know.

shobull commented 1 month ago

Hi @ananzh,

I tried Firefox & Chrome (latest stable releases)

None of above helped.

I'm seeing the same behaviour as @jonashellmann (losing all filters parameters from URL) as he described in Additional context.

necoras commented 1 month ago

Hello @ananzh

I'm also able to replicate this behavior, as are multiple other co-workers across multiple computers and multiple browsers. We're running OpenSearch 2.13 in AWS. Thanks.

vinylen commented 1 month ago

We are also seeing the same error as @shobull. Sharing via the "Share" button and selecting "SNAPSHOT" results in the error message that shobull mentioned:

image

throwUnableToRestoreUrlError@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:117886
retrieveState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:118156
decodeState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:119249
getStatesFromOsdUrl/<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:122323
getStatesFromOsdUrl@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:122277
getStateFromOsdUrl@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:122486
get@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:129569
connectStorageToQueryState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/data/data.plugin.js:1:378204
TopNav@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/discover/discover.chunk.4.js:1:42603
$i@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:57931
Na@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:66792
gs@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:105389
uc@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:96720
sc@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:96643
Qs@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:93673
Vo/<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45315
__osdSharedDeps__</t.unstable_runWithPriority@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:443:3844
Xo@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45024
Vo@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45262
Yo@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45195
$s@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:90458
enqueueSetState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:48980
__osdSharedDeps__</v.prototype.setState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:419:1297
t/n.unlisten<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:349:230858
setupHistoryListener/unlisten</<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:15:127893
setupHistoryListener/unlisten<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:15:127866
e@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:206211
notifyListeners/<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:206441
notifyListeners@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:206411
p@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:207942
w/<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:208163
confirmTransitionTo@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:206151
w@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:208118
g@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:208023

Users are using a mix of Firefox & Chrome, we're running OpenSearch 2.16 and OpenSearch-Dashboards 2.16.

vinylen commented 1 month ago

We are also seeing the same error as @shobull. Sharing via the "Share" button and selecting "SNAPSHOT" results in the error message that shobull mentioned:

image

throwUnableToRestoreUrlError@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:117886
retrieveState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:118156
decodeState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:119249
getStatesFromOsdUrl/<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:122323
getStatesFromOsdUrl@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:122277
getStateFromOsdUrl@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:122486
get@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/opensearchDashboardsUtils/opensearchDashboardsUtils.plugin.js:1:129569
connectStorageToQueryState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/data/data.plugin.js:1:378204
TopNav@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/plugin/discover/discover.chunk.4.js:1:42603
$i@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:57931
Na@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:66792
gs@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:105389
uc@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:96720
sc@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:96643
Qs@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:93673
Vo/<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45315
__osdSharedDeps__</t.unstable_runWithPriority@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:443:3844
Xo@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45024
Vo@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45262
Yo@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45195
$s@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:90458
enqueueSetState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:48980
__osdSharedDeps__</v.prototype.setState@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:419:1297
t/n.unlisten<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:349:230858
setupHistoryListener/unlisten</<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:15:127893
setupHistoryListener/unlisten<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:15:127866
e@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:206211
notifyListeners/<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:206441
notifyListeners@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:206411
p@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:207942
w/<@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:208163
confirmTransitionTo@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:206151
w@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:208118
g@https://opensearch-leader01.example-domain.dc06.region-example.io:5601/7858/bundles/core/core.entry.js:6:208023

Users are using a mix of Firefox & Chrome, we're running OpenSearch 2.16 and OpenSearch-Dashboards 2.16.

FWIW, we solved this by disabling the option "state:storeInSessionStorage" in Advanced settings for OpenSearch-Dashboards. Users then had to recreate the shared URLs. We found the cause here: https://github.com/elastic/kibana/issues/126907#issuecomment-1060501397

necoras commented 1 month ago

@vinylen I'm able confirm the same behavior with that setting.

The answer on that linked issue is "working as intended, won't fix." So, the intention is that shared links just don't work when session storage is turned on? That seems like a terrible response. At the very least turning on that setting should disable the share functionality so that users don't get confusing error messages and bad links.

To add to this situation, we're having to disable that setting every few days. Either some user is resetting it (which can't be prevented as it's impossible to prevent most users from accessing and changing those settings until some nebulous future dashboard rework is done.), or some automated process is resetting it. Which is its own problem.

rayangou commented 1 month ago

We are also facing the same issue in OpenSearch dashboards 2.15.

The query filters are lost when the page is loaded. Note: sessionInStorage is disabled