Skip to content

[9.0] [visualize] fix Save to library action from a by value panel breaks the chart panel (#210125)#211052

Merged
kibanamachine merged 1 commit intoelastic:9.0from
kibanamachine:backport/9.0/pr-210125
Feb 13, 2025
Merged

[9.0] [visualize] fix Save to library action from a by value panel breaks the chart panel (#210125)#211052
kibanamachine merged 1 commit intoelastic:9.0from
kibanamachine:backport/9.0/pr-210125

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.0:

Questions ?

Please refer to the Backport tool documentation

…he chart panel (elastic#210125)

Fixes elastic#206921

### Problem
The visualize embeddable is inconstant when passing runtime state to
`buildEmbeddable`. Sometimes, only `{ savedObjectId }` is provided. The
embeddable tried to work around this by calling `deserializeState` in
`buildEmbeddable`.

There was a different bug with the `deserializeState` guard in
`buildEmbeddable` where state like `{ savedObjectId, savedVis: {} }`
would not pass the guard. Dashboard adds runtime state so `savedVis` was
getting added to `initialState` and thus failing the guard

This resulted in the visualize embeddable trying to initialize with
state `{ savedObjectId }` instead of state in the shape `{
savedObjectId, serializedVis: {} }`. This resulted in error message like
"Could not read properties of undefined" when the embeddable tried to
read from `state.serializedVis.type`.

### Solution
The solution is to ensure that `buildEmbeddable` is always passed
runtime state containing `serializedVis`. This pattern is in line with
the lens embeddable.

### Test instructions
* install sample web logs
* create agg based visualization
* create new dashboard, add agg based visualization. Open context menu
of vis and select "Unlink from library". (Side note, removing legacy
visualizations from add panel makes it hard to add by-value agg based
visualizations to a dashboard)
* save dashboard
* edit agg based vis
* Click "Save to library" and fill out form
* Verify visualization is rendered in dashboard.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 109dcce)
@kibanamachine kibanamachine merged commit 2b69ea0 into elastic:9.0 Feb 13, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
visualizations 507 506 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
visualizations 366.5KB 369.7KB +3.1KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
visualizations 38.5KB 38.7KB +138.0B
Unknown metric groups

async chunk count

id before after diff
visualizations 19 20 +1

cc @nreese

nreese added a commit that referenced this pull request Feb 19, 2025
…reaks the chart panel (#210125) (#211663)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[visualize] fix Save to library action from a by value panel breaks
the chart panel
(#210125)](#210125)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Nathan
Reese","email":"reese.nathan@elastic.co"},"sourceCommit":{"committedDate":"2025-02-13T17:09:29Z","message":"[visualize]
fix Save to library action from a by value panel breaks the chart panel
(#210125)\n\nFixes
https://github.com/elastic/kibana/issues/206921\r\n\r\n###
Problem\r\nThe visualize embeddable is inconstant when passing runtime
state to\r\n`buildEmbeddable`. Sometimes, only `{ savedObjectId }` is
provided. The\r\nembeddable tried to work around this by calling
`deserializeState` in\r\n`buildEmbeddable`.\r\n\r\nThere was a different
bug with the `deserializeState` guard in\r\n`buildEmbeddable` where
state like `{ savedObjectId, savedVis: {} }`\r\nwould not pass the
guard. Dashboard adds runtime state so `savedVis` was\r\ngetting added
to `initialState` and thus failing the guard\r\n\r\nThis resulted in the
visualize embeddable trying to initialize with\r\nstate `{ savedObjectId
}` instead of state in the shape `{\r\nsavedObjectId, serializedVis: {}
}`. This resulted in error message like\r\n\"Could not read properties
of undefined\" when the embeddable tried to\r\nread from
`state.serializedVis.type`.\r\n\r\n### Solution\r\nThe solution is to
ensure that `buildEmbeddable` is always passed\r\nruntime state
containing `serializedVis`. This pattern is in line with\r\nthe lens
embeddable.\r\n\r\n### Test instructions\r\n* install sample web
logs\r\n* create agg based visualization\r\n* create new dashboard, add
agg based visualization. Open context menu\r\nof vis and select \"Unlink
from library\". (Side note, removing legacy\r\nvisualizations from add
panel makes it hard to add by-value agg based\r\nvisualizations to a
dashboard)\r\n* save dashboard\r\n* edit agg based vis\r\n* Click \"Save
to library\" and fill out form\r\n* Verify visualization is rendered in
dashboard.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"109dcce33864a4d8be2e5dc6ac088d8a9976afb5","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","backport
missing","v9.0.0","project:embeddableRebuild","backport:version","v8.18.0","v9.1.0","v8.19.0","v8.17.3","v8.16.5"],"title":"[visualize]
fix Save to library action from a by value panel breaks the chart
panel","number":210125,"url":"https://github.com/elastic/kibana/pull/210125","mergeCommit":{"message":"[visualize]
fix Save to library action from a by value panel breaks the chart panel
(#210125)\n\nFixes
https://github.com/elastic/kibana/issues/206921\r\n\r\n###
Problem\r\nThe visualize embeddable is inconstant when passing runtime
state to\r\n`buildEmbeddable`. Sometimes, only `{ savedObjectId }` is
provided. The\r\nembeddable tried to work around this by calling
`deserializeState` in\r\n`buildEmbeddable`.\r\n\r\nThere was a different
bug with the `deserializeState` guard in\r\n`buildEmbeddable` where
state like `{ savedObjectId, savedVis: {} }`\r\nwould not pass the
guard. Dashboard adds runtime state so `savedVis` was\r\ngetting added
to `initialState` and thus failing the guard\r\n\r\nThis resulted in the
visualize embeddable trying to initialize with\r\nstate `{ savedObjectId
}` instead of state in the shape `{\r\nsavedObjectId, serializedVis: {}
}`. This resulted in error message like\r\n\"Could not read properties
of undefined\" when the embeddable tried to\r\nread from
`state.serializedVis.type`.\r\n\r\n### Solution\r\nThe solution is to
ensure that `buildEmbeddable` is always passed\r\nruntime state
containing `serializedVis`. This pattern is in line with\r\nthe lens
embeddable.\r\n\r\n### Test instructions\r\n* install sample web
logs\r\n* create agg based visualization\r\n* create new dashboard, add
agg based visualization. Open context menu\r\nof vis and select \"Unlink
from library\". (Side note, removing legacy\r\nvisualizations from add
panel makes it hard to add by-value agg based\r\nvisualizations to a
dashboard)\r\n* save dashboard\r\n* edit agg based vis\r\n* Click \"Save
to library\" and fill out form\r\n* Verify visualization is rendered in
dashboard.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"109dcce33864a4d8be2e5dc6ac088d8a9976afb5"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/211052","number":211052,"state":"MERGED","mergeCommit":{"sha":"2b69ea053f47e0b698884bd5d549042a5c5ad9bc","message":"[9.0]
[visualize] fix Save to library action from a by value panel breaks the
chart panel (#210125) (#211052)\n\n# Backport\n\nThis will backport the
following commits from `main` to `9.0`:\n- [[visualize] fix Save to
library action from a by value panel breaks\nthe chart
panel\n(#210125)](https://github.com/elastic/kibana/pull/210125)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by:
Nathan Reese
<reese.nathan@elastic.co>"}},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/211050","number":211050,"state":"OPEN"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210125","number":210125,"mergeCommit":{"message":"[visualize]
fix Save to library action from a by value panel breaks the chart panel
(#210125)\n\nFixes
https://github.com/elastic/kibana/issues/206921\r\n\r\n###
Problem\r\nThe visualize embeddable is inconstant when passing runtime
state to\r\n`buildEmbeddable`. Sometimes, only `{ savedObjectId }` is
provided. The\r\nembeddable tried to work around this by calling
`deserializeState` in\r\n`buildEmbeddable`.\r\n\r\nThere was a different
bug with the `deserializeState` guard in\r\n`buildEmbeddable` where
state like `{ savedObjectId, savedVis: {} }`\r\nwould not pass the
guard. Dashboard adds runtime state so `savedVis` was\r\ngetting added
to `initialState` and thus failing the guard\r\n\r\nThis resulted in the
visualize embeddable trying to initialize with\r\nstate `{ savedObjectId
}` instead of state in the shape `{\r\nsavedObjectId, serializedVis: {}
}`. This resulted in error message like\r\n\"Could not read properties
of undefined\" when the embeddable tried to\r\nread from
`state.serializedVis.type`.\r\n\r\n### Solution\r\nThe solution is to
ensure that `buildEmbeddable` is always passed\r\nruntime state
containing `serializedVis`. This pattern is in line with\r\nthe lens
embeddable.\r\n\r\n### Test instructions\r\n* install sample web
logs\r\n* create agg based visualization\r\n* create new dashboard, add
agg based visualization. Open context menu\r\nof vis and select \"Unlink
from library\". (Side note, removing legacy\r\nvisualizations from add
panel makes it hard to add by-value agg based\r\nvisualizations to a
dashboard)\r\n* save dashboard\r\n* edit agg based vis\r\n* Click \"Save
to library\" and fill out form\r\n* Verify visualization is rendered in
dashboard.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"109dcce33864a4d8be2e5dc6ac088d8a9976afb5"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/211051","number":211051,"state":"MERGED","mergeCommit":{"sha":"1b7c334e9035bc93ee47e43b1d739e816a95898a","message":"[8.x]
[visualize] fix Save to library action from a by value panel breaks the
chart panel (#210125) (#211051)\n\n# Backport\n\nThis will backport the
following commits from `main` to `8.x`:\n- [[visualize] fix Save to
library action from a by value panel breaks\nthe chart
panel\n(#210125)](https://github.com/elastic/kibana/pull/210125)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by:
Nathan Reese
<reese.nathan@elastic.co>"}},{"branch":"8.17","label":"v8.17.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/211054","number":211054,"state":"MERGED","mergeCommit":{"sha":"ed6b3573771032ad3a37ae272be5a3bdcdfad7b0","message":"[8.17]
[visualize] fix Save to library action from a by value panel breaks the
chart panel (#210125) (#211054)\n\n# Backport\n\nThis will backport the
following commits from `main` to `8.17`:\n- [[visualize] fix Save to
library action from a by value panel breaks\nthe chart
panel\n(#210125)](https://github.com/elastic/kibana/pull/210125)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>"}},{"branch":"8.16","label":"v8.16.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/211057","number":211057,"state":"MERGED","mergeCommit":{"sha":"0f2874417ece3c735e4091f885ad6f4b5d426da1","message":"[8.16]
[visualize] fix Save to library action from a by value panel breaks the
chart panel (#210125) (#211057)\n\n# Backport\n\nThis will backport the
following commits from `main` to `8.16`:\n- [[visualize] fix Save to
library action from a by value panel breaks\nthe chart
panel\n(#210125)](https://github.com/elastic/kibana/pull/210125)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\n---------\n\nCo-authored-by:
kibanamachine <42973632+kibanamachine@users.noreply.github.com>"}}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants