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

[Dashboard] Fix missing state on short URL alias match redirect #163658

Merged
merged 4 commits into from Aug 11, 2023

Conversation

ThomThomson
Copy link
Contributor

@ThomThomson ThomThomson commented Aug 10, 2023

Summary

Fixes an issue where URL state from short URLs could be lost on an alias match redirect.

Before
before

After
After

Note
In the after gif - and in any testing, you'll notice that the fixed version shows an error in the Lens Embeddable. This is because the short URL contains a panels key with an un-migrated version of the by value Lens panel on the Dashboard. This would not have happened if I had used a by reference panel, and newer versions of Kibana have warnings in place to prevent the saving of un-migrated state to a short URL in this way.

To test:

  1. Download and extract this ES data which has two Dashboards in two spaces (with a URL conflict) and has a short URL pointing to the conflicting Dashboard URL with a filter attached.
    esData_short_url_alias_redirect.zip

  2. Start ES pointing to where you extraced that data yarn es snapshot -E path.data=path/to/data

  3. Try navigating to the short URL {Your_local_url}/s/new-space/goto/efbe7e20-37ae-11ee-8876-5107f2fdfac9

  4. The Dashboard should load properly, with the filter set.

Checklist

Delete any items that are not applicable to this PR.

@ThomThomson ThomThomson added Feature:Dashboard Dashboard related features Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:small Small Level of Effort impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. labels Aug 10, 2023
@ThomThomson
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -59,6 +59,16 @@ test('returns undefined when provided validation function returns redireted', as
expect(dashboard).toBeUndefined();
});

test('does not get initial input when provided validation function returns redireted', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - typo redireted => redirected

How did loading input cause the filters to disappear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically when state is loaded into the Dashboard via the _a param, the _a param gets deleted so it doesn't keep overriding the Dashboard's current state.

This process was happening before the redirect instead of after.

Copy link
Contributor

Choose a reason for hiding this comment

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

so getInitialInput modifies the URL, then redirect was getting called. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes exactly.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, thanks for the explaination.

There is a bit of a problem with encapsulation, where a create_dashboard test is protecting against a side effect from a callbacks.

I think a clarity in callback name, or test naming, or comments should be added to explain this side effect

How about one or some of the following

  1. rename getInitialInput callback to getInitialInputAndRemoveStateFromUrl to clarify what callback does and highlight side effect of callback.
  2. add comment where getInitialInput callback is called that method modifies URL
  3. renaming the test case to include the "why". Something like "does not modify URL when validation function returns redirected"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The encapsulation concern is completely valid. The reason I left it generic in this way is because the Dashboard container code is usable in many places - most of which have no special URL treatment at all. The method getInitialInput can theoretically have any number of side effects.

IMO, in all of these cases it is actually more correct for getInitialInput to be called only once we're certain that the loaded saved object (if there is one) passes validation. This is why I named the test this way and didn't rename anything to mention the URLs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for explaining, I had not considered portable dashboards where there is no URL.

How about just a comment in the testing stating that for dashboard application, side effect of getInitialInput removes _a from URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea. Added a comment in aee1b09

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

changes LGTM. Thanks for adding the comment for the test case

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

@ThomThomson ThomThomson marked this pull request as ready for review August 11, 2023 16:14
@ThomThomson ThomThomson requested a review from a team as a code owner August 11, 2023 16:14
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@ThomThomson ThomThomson merged commit 4de6111 into elastic:main Aug 11, 2023
21 checks passed
@kibanamachine kibanamachine added v8.10.0 backport:skip This commit does not require backporting labels Aug 11, 2023
@ThomThomson ThomThomson added backport:prev-minor Backport to the previous minor version (i.e. one version back from main) v8.9.2 and removed backport:skip This commit does not require backporting labels Aug 11, 2023
ThomThomson added a commit to ThomThomson/kibana that referenced this pull request Aug 11, 2023
…tic#163658)

Fixes an issue where URL state from short URLs could be lost on an alias match redirect.

(cherry picked from commit 4de6111)
ThomThomson added a commit that referenced this pull request Aug 11, 2023
…#163658) (#163746)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Dashboard] Fix missing state on short URL alias match redirect
(#163658)](#163658)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Devon
Thomson","email":"devon.thomson@elastic.co"},"sourceCommit":{"committedDate":"2023-08-11T16:15:18Z","message":"[Dashboard]
Fix missing state on short URL alias match redirect (#163658)\n\nFixes
an issue where URL state from short URLs could be lost on an alias match
redirect.","sha":"4de61111b14b59d2b57758a35ef47618c3a9ba46","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Dashboard","release_note:fix","Team:Presentation","loe:hours","impact:high","backport:prev-minor","v8.10.0","v8.9.2"],"number":163658,"url":"#163658
Fix missing state on short URL alias match redirect (#163658)\n\nFixes
an issue where URL state from short URLs could be lost on an alias match
redirect.","sha":"4de61111b14b59d2b57758a35ef47618c3a9ba46"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"#163658
Fix missing state on short URL alias match redirect (#163658)\n\nFixes
an issue where URL state from short URLs could be lost on an alias match
redirect.","sha":"4de61111b14b59d2b57758a35ef47618c3a9ba46"}},{"branch":"8.9","label":"v8.9.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
@sorenlouv sorenlouv added auto-backport Deprecated: Automatically backport this PR after it's merged v8.8.0 and removed auto-backport Deprecated: Automatically backport this PR after it's merged v8.8.0 labels Aug 11, 2023
benakansara pushed a commit to benakansara/kibana that referenced this pull request Aug 14, 2023
…tic#163658)

Fixes an issue where URL state from short URLs could be lost on an alias match redirect.
@mistic mistic removed the v8.9.1 label Aug 17, 2023
@mistic
Copy link
Member

mistic commented Aug 17, 2023

This pr didn't make it into the build candidate for v8.9.1. Updating the labels.

Heenawter added a commit that referenced this pull request Jan 26, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](#166896), I added [dashboard
caching](#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...


https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_ 

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**


https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f


**After**


https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1


### Testing
To test, I followed the directions from [this PR
description](#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 26, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...

https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**

https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f

**After**

https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1

### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

(cherry picked from commit 27b34d5)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 26, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...

https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**

https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f

**After**

https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1

### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

(cherry picked from commit 27b34d5)
kibanamachine added a commit that referenced this pull request Jan 26, 2024
# Backport

This will backport the following commits from `main` to `8.12`:
- [[Dashboard] Only cache non-alias dashboards
(#175635)](#175635)

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

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

<!--BACKPORT [{"author":{"name":"Hannah
Mudge","email":"Heenawter@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-01-26T16:09:28Z","message":"[Dashboard]
Only cache non-alias dashboards (#175635)\n\n## Summary\r\n\r\nThis PR
fixes the alias redirect problem that was noted in the
attached\r\nSDH.\r\n\r\nFor context, as part of the [Links
panel\r\nwork](#166896), I added
[dashboard\r\ncaching](#162285) to
make\r\nnavigation more efficient - however, when implementing this, I
did not\r\nconsider the redirect behaviour.\r\n\r\nSpecifically, we were
**always** adding dashboards to the cache, even if\r\nthe load outcome
meant a redirect was necessary - so, because the meta\r\ninfo for the
dashboard fetch result was cached, this meant that the\r\n`'aliasMatch'`
outcome was **also** cached. Because of this, after a\r\nredirect
happened, the second attempt to load the dashboard would return\r\nthe
result from the **cache** rather than fetching the dashboard from\r\nthe
CM client - but, as described previously, the cached dashboard
would\r\nstill appear as though it required a redirect because the
cached outcome\r\nwas `'aliasMatch'`.\r\n\r\nTherefore, because of
hitting this early return on **both** fetch\r\nattempts (before the
redirect, after the
redirect)...\r\n\r\n\r\nhttps://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171\r\n\r\n...
the dashboard information would not get updated. _(Oof!)_
\r\n\r\nDespite the lengthy description of the problem, the solution is
quite\r\nsimple - just don't add dashboards to the cache if they require
a\r\nredirect. And then everything works! 🎉\r\n\r\n###
Videos\r\n**Before**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f\r\n\r\n\r\n**After**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1\r\n\r\n\r\n###
Testing\r\nTo test, I followed the directions from [this
PR\r\ndescription](#163658) to get
a\r\ndashboard that requires a redirect - then, I created a markdown
panel\r\nwith the **old** (from the Default space) dashboard ID in the
new space\r\nto see the same redirect behaviour that the customer in the
SDH was\r\nseeing.\r\n\r\n### Checklist\r\n- [x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"27b34d591111a878001eaac7b0f3ef0173bc8f02","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Feature:Dashboard","release_note:fix","Team:Presentation","loe:small","impact:high","backport:prev-minor","v8.12.1","v8.13.0"],"title":"[Dashboard]
Only cache non-alias
dashboards","number":175635,"url":"#175635
Only cache non-alias dashboards (#175635)\n\n## Summary\r\n\r\nThis PR
fixes the alias redirect problem that was noted in the
attached\r\nSDH.\r\n\r\nFor context, as part of the [Links
panel\r\nwork](#166896), I added
[dashboard\r\ncaching](#162285) to
make\r\nnavigation more efficient - however, when implementing this, I
did not\r\nconsider the redirect behaviour.\r\n\r\nSpecifically, we were
**always** adding dashboards to the cache, even if\r\nthe load outcome
meant a redirect was necessary - so, because the meta\r\ninfo for the
dashboard fetch result was cached, this meant that the\r\n`'aliasMatch'`
outcome was **also** cached. Because of this, after a\r\nredirect
happened, the second attempt to load the dashboard would return\r\nthe
result from the **cache** rather than fetching the dashboard from\r\nthe
CM client - but, as described previously, the cached dashboard
would\r\nstill appear as though it required a redirect because the
cached outcome\r\nwas `'aliasMatch'`.\r\n\r\nTherefore, because of
hitting this early return on **both** fetch\r\nattempts (before the
redirect, after the
redirect)...\r\n\r\n\r\nhttps://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171\r\n\r\n...
the dashboard information would not get updated. _(Oof!)_
\r\n\r\nDespite the lengthy description of the problem, the solution is
quite\r\nsimple - just don't add dashboards to the cache if they require
a\r\nredirect. And then everything works! 🎉\r\n\r\n###
Videos\r\n**Before**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f\r\n\r\n\r\n**After**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1\r\n\r\n\r\n###
Testing\r\nTo test, I followed the directions from [this
PR\r\ndescription](#163658) to get
a\r\ndashboard that requires a redirect - then, I created a markdown
panel\r\nwith the **old** (from the Default space) dashboard ID in the
new space\r\nto see the same redirect behaviour that the customer in the
SDH was\r\nseeing.\r\n\r\n### Checklist\r\n- [x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"27b34d591111a878001eaac7b0f3ef0173bc8f02"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/175635","number":175635,"mergeCommit":{"message":"[Dashboard]
Only cache non-alias dashboards (#175635)\n\n## Summary\r\n\r\nThis PR
fixes the alias redirect problem that was noted in the
attached\r\nSDH.\r\n\r\nFor context, as part of the [Links
panel\r\nwork](#166896), I added
[dashboard\r\ncaching](#162285) to
make\r\nnavigation more efficient - however, when implementing this, I
did not\r\nconsider the redirect behaviour.\r\n\r\nSpecifically, we were
**always** adding dashboards to the cache, even if\r\nthe load outcome
meant a redirect was necessary - so, because the meta\r\ninfo for the
dashboard fetch result was cached, this meant that the\r\n`'aliasMatch'`
outcome was **also** cached. Because of this, after a\r\nredirect
happened, the second attempt to load the dashboard would return\r\nthe
result from the **cache** rather than fetching the dashboard from\r\nthe
CM client - but, as described previously, the cached dashboard
would\r\nstill appear as though it required a redirect because the
cached outcome\r\nwas `'aliasMatch'`.\r\n\r\nTherefore, because of
hitting this early return on **both** fetch\r\nattempts (before the
redirect, after the
redirect)...\r\n\r\n\r\nhttps://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171\r\n\r\n...
the dashboard information would not get updated. _(Oof!)_
\r\n\r\nDespite the lengthy description of the problem, the solution is
quite\r\nsimple - just don't add dashboards to the cache if they require
a\r\nredirect. And then everything works! 🎉\r\n\r\n###
Videos\r\n**Before**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f\r\n\r\n\r\n**After**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1\r\n\r\n\r\n###
Testing\r\nTo test, I followed the directions from [this
PR\r\ndescription](#163658) to get
a\r\ndashboard that requires a redirect - then, I created a markdown
panel\r\nwith the **old** (from the Default space) dashboard ID in the
new space\r\nto see the same redirect behaviour that the customer in the
SDH was\r\nseeing.\r\n\r\n### Checklist\r\n- [x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"27b34d591111a878001eaac7b0f3ef0173bc8f02"}}]}]
BACKPORT-->

Co-authored-by: Hannah Mudge <Heenawter@users.noreply.github.com>
lcawl pushed a commit to lcawl/kibana that referenced this pull request Jan 26, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...


https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_ 

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**


https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f


**After**


https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1


### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...


https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_ 

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**


https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f


**After**


https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1


### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...


https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_ 

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**


https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f


**After**


https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1


### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to the previous minor version (i.e. one version back from main) Feature:Dashboard Dashboard related features impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:small Small Level of Effort release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.9.2 v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants