[Controls] Restore fallback to dataViewId stored explicitly in control state#255878
Conversation
|
Pinging @elastic/kibana-presentation (Team:Presentation) |
| ...DEFAULT_DATA_CONTROL_STATE, | ||
| title, | ||
| data_view_id: dataViewRef?.id ?? '', // get the data view ID from the reference | ||
| data_view_id: dataViewRef?.id ?? state.dataViewId ?? '', // get the data view ID from the reference, or fall back to an explicitly stored dataViewId |
There was a problem hiding this comment.
if both of them are missing, should we just throw instead if fallback to an empty id that would cause other issues in the flow?
There was a problem hiding this comment.
I'm testing this with the dashboard I shared on Slack and it doesn't seems to work:
before this return, if I print out dataViewRef and state.dataViewId I got this:
{
dataViewRef: {
name: 'b26a76ac-d257-4144-bd62-c70651312b37:optionsListDataView',
type: 'index-pattern',
id: ''
},
state: {
use_global_filters: true,
ignore_validations: false,
field_name: 'resource.attributes.host.name',
exclude: false,
sort: { by: '_count', direction: 'desc' },
exists_selected: false,
run_past_timeout: false,
search_technique: 'exact',
selected_options: [],
single_select: true,
dataViewRefName: 'b26a76ac-d257-4144-bd62-c70651312b37:optionsListDataView'
}
}
There was a problem hiding this comment.
Ah. Well. In that case it looks like you've got a busted dataViewRef.
This PR will unfortunately not fix that particular dashboard. It'll fix some other dashboards that are breaking in other ways.
I'll add a throw for cases like this.
There was a problem hiding this comment.
@markov00 Reverting this throw. The data control needs to have a data_view_id of '' for its own internal error handling around missing data views. Throwing in the transform was causing the control to never render at all and broke several Scout tests
…-fix # Conflicts: # src/platform/plugins/shared/controls/server/transforms/data_control_transforms.ts
…kibana into 888-852-control-ref-fix # Conflicts: # src/platform/plugins/shared/controls/server/transforms/data_control_transforms.ts
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
History
|
Heenawter
left a comment
There was a problem hiding this comment.
LGTM - code review only. Nice test additions 🎉
Part of #255826 ## Summary This PR swaps `uid` to `id` for Dashboard panels + pinned panels. Noting here that `id` was used to store saved object ID in versions <8.19, so this was something we had to consider for BWC. However, I tested the following app states in the URL + saved objects and everything worked as expected: <details> <summary>v8.18</summary> - [test-8.18.ndjson.zip](https://github.com/user-attachments/files/26359938/test-8.18.ndjson.zip) - [logs-8.18.ndjson.zip](https://github.com/user-attachments/files/26392120/logs-8.18.ndjson.zip) - URL with saved object ID stored as `id`: ``` &_a=(panels:!((gridData:(h:15,i:'4d73a866-de65-4708-80f8-a5b16b50b617',w:24,x:8,y:0),id:'2f360f30-ea74-11eb-b4c6-3d2afc1cb389',panelConfig:(description:'',enhancements:(dynamicActions:(events:!())),grid:()),panelIndex:'4d73a866-de65-4708-80f8-a5b16b50b617',title:'%5BLogs%5D%20Visits',type:search))) ``` - URL with by value panel: ``` &_a=(panels:!((gridData:(h:15,i:'02c1205b-f16f-4293-b48c-92bdd5cc0eff',w:24,x:24,y:0),panelConfig:(attributes:(references:!((id:'90943e30-9a47-11e8-b64d-95841ca0b247',name:indexpattern-datasource-layer-037637f9-cbf2-4dfc-99bf-289955769449,type:index-pattern)),state:(adHocDataViews:(),datasourceStates:(formBased:(layers:('037637f9-cbf2-4dfc-99bf-289955769449':(columnOrder:!(f5e724f1-8ff3-4e8c-b628-d9e5c23354f5,'1166b96c-bd7f-4217-a6fb-090a665cd4be'),columns:('1166b96c-bd7f-4217-a6fb-090a665cd4be':(dataType:number,isBucketed:!f,label:'Count%20of%20records',operationType:count,params:(emptyAsNull:!t),scale:ratio,sourceField:___records___),f5e724f1-8ff3-4e8c-b628-d9e5c23354f5:(dataType:string,isBucketed:!t,label:'Top%205%20values%20of%20extension.keyword',operationType:terms,params:(exclude:!(),excludeIsRegex:!f,include:!(),includeIsRegex:!f,missingBucket:!f,orderBy:(columnId:'1166b96c-bd7f-4217-a6fb-090a665cd4be',type:column),orderDirection:desc,otherBucket:!t,parentFormat:(id:terms),size:5),scale:ordinal,sourceField:extension.keyword)),incompleteColumns:(),sampling:1))),indexpattern:(layers:()),textBased:(layers:())),filters:!(),internalReferences:!(),query:(language:kuery,query:''),visualization:(axisTitlesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),fittingFunction:Linear,gridlinesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),labelsOrientation:(x:0,yLeft:0,yRight:0),layers:!((accessors:!('1166b96c-bd7f-4217-a6fb-090a665cd4be'),colorMapping:(assignments:!(),colorMode:(type:categorical),paletteId:eui_amsterdam_color_blind,specialAssignments:!((color:(type:loop),rule:(type:other),touched:!f))),layerId:'037637f9-cbf2-4dfc-99bf-289955769449',layerType:data,position:top,seriesType:bar_stacked,showGridlines:!f,xAccessor:f5e724f1-8ff3-4e8c-b628-d9e5c23354f5)),legend:(isVisible:!t,position:right),preferredSeriesType:bar_stacked,tickLabelsVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),valueLabels:hide)),title:'',type:lens,visualizationType:lnsXY),enhancements:(dynamicActions:(events:!())),filters:!(),query:(language:kuery,query:''),syncColors:!f,syncCursor:!t,syncTooltips:!f),panelIndex:'02c1205b-f16f-4293-b48c-92bdd5cc0eff',type:lens))) ``` </details> <details> <summary>v8.19</summary> - [test-8.19.ndjson.zip](https://github.com/user-attachments/files/26359955/test-8.19.ndjson.zip) - [logs-8.19.ndjson.zip](https://github.com/user-attachments/files/26392124/logs-8.19.ndjson.zip) - URL with saved object ID stored as `savedObjectId`: ``` &_a=(panels:!((gridData:(h:15,i:'0beaeb76-c8f6-4124-a24e-5bf325009857',w:24,x:17,y:0),panelConfig:(savedObjectId:'2f360f30-ea74-11eb-b4c6-3d2afc1cb389'),panelIndex:'0beaeb76-c8f6-4124-a24e-5bf325009857',panelRefName:panel_0beaeb76-c8f6-4124-a24e-5bf325009857,type:search)),references:!((id:'90943e30-9a47-11e8-b64d-95841ca0b247',name:'0beaeb76-c8f6-4124-a24e-5bf325009857:kibanaSavedObjectMeta.searchSourceJSON.index',type:index-pattern),(id:'2f360f30-ea74-11eb-b4c6-3d2afc1cb389',name:'0beaeb76-c8f6-4124-a24e-5bf325009857:panel_0beaeb76-c8f6-4124-a24e-5bf325009857',type:search),(id:'2f360f30-ea74-11eb-b4c6-3d2afc1cb389',name:'0beaeb76-c8f6-4124-a24e-5bf325009857:panel_0beaeb76-c8f6-4124-a24e-5bf325009857',type:search)),viewMode:edit) ``` - URL with by value panel: ``` &_a=(panels:!((gridData:(h:15,i:'14d0414a-44e6-4d81-bc6a-10bd94fa7b6d',w:24,x:9,y:0),panelConfig:(attributes:(references:!((id:'90943e30-9a47-11e8-b64d-95841ca0b247',name:indexpattern-datasource-layer-6e9298a5-fe0c-4884-a8d5-bd41462629cd,type:index-pattern)),state:(adHocDataViews:(),datasourceStates:(formBased:(layers:('6e9298a5-fe0c-4884-a8d5-bd41462629cd':(columnOrder:!('9ca13d25-8cd4-47d4-94e2-6ba80bbe0405','1b76996f-6905-4d05-9c3e-3e5e93803f69'),columns:('1b76996f-6905-4d05-9c3e-3e5e93803f69':(dataType:number,isBucketed:!f,label:'Count%20of%20records',operationType:count,params:(emptyAsNull:!t),sourceField:___records___),'9ca13d25-8cd4-47d4-94e2-6ba80bbe0405':(dataType:string,isBucketed:!t,label:'Top%205%20values%20of%20extension.keyword',operationType:terms,params:(exclude:!(),excludeIsRegex:!f,include:!(),includeIsRegex:!f,missingBucket:!f,orderBy:(columnId:'1b76996f-6905-4d05-9c3e-3e5e93803f69',type:column),orderDirection:desc,otherBucket:!t,parentFormat:(id:terms),size:5),sourceField:extension.keyword)),incompleteColumns:(),sampling:1))),indexpattern:(layers:()),textBased:(layers:())),filters:!(),internalReferences:!(),query:(language:kuery,query:''),visualization:(axisTitlesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),fittingFunction:Linear,gridlinesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),labelsOrientation:(x:0,yLeft:0,yRight:0),layers:!((accessors:!('1b76996f-6905-4d05-9c3e-3e5e93803f69'),colorMapping:(assignments:!(),colorMode:(type:categorical),paletteId:default,specialAssignments:!((color:(type:loop),rules:!((type:other)),touched:!f))),layerId:'6e9298a5-fe0c-4884-a8d5-bd41462629cd',layerType:data,position:top,seriesType:bar_stacked,showGridlines:!f,xAccessor:'9ca13d25-8cd4-47d4-94e2-6ba80bbe0405')),legend:(isVisible:!t,position:right),preferredSeriesType:bar_stacked,tickLabelsVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),valueLabels:hide)),title:'',type:lens,visualizationType:lnsXY),enhancements:(dynamicActions:(events:!())),filters:!(),query:(language:kuery,query:''),syncColors:!f,syncCursor:!t,syncTooltips:!f),panelIndex:'14d0414a-44e6-4d81-bc6a-10bd94fa7b6d',type:lens)),references:!((id:'90943e30-9a47-11e8-b64d-95841ca0b247',name:'14d0414a-44e6-4d81-bc6a-10bd94fa7b6d:indexpattern-datasource-layer-6e9298a5-fe0c-4884-a8d5-bd41462629cd',type:index-pattern)),viewMode:edit) ``` </details> <details> <summary>v9.0</summary> - [test-9.0.ndjson.zip](https://github.com/user-attachments/files/26359965/test-9.0.ndjson.zip) - [logs-9.0.ndjson.zip](https://github.com/user-attachments/files/26392128/logs-9.0.ndjson.zip) - URL with saved object ID stored as `id`: ``` &_a=(panels:!((gridData:(h:15,i:ee853f31-4058-4d93-a707-d8e4d56cf74a,w:24,x:6,y:0),id:'2f360f30-ea74-11eb-b4c6-3d2afc1cb389',panelConfig:(description:'',enhancements:(dynamicActions:(events:!())),grid:()),panelIndex:ee853f31-4058-4d93-a707-d8e4d56cf74a,title:'%5BLogs%5D%20Visits',type:search))) ``` - URL with by value panel: ``` &_a=(panels:!((gridData:(h:15,i:'82fedfe7-5e35-4577-8341-f96aec301d45',w:24,x:5,y:0),panelConfig:(attributes:(references:!((id:'90943e30-9a47-11e8-b64d-95841ca0b247',name:indexpattern-datasource-layer-e8c1622f-42a3-4ba0-8ef1-1e2de6870681,type:index-pattern)),state:(adHocDataViews:(),datasourceStates:(formBased:(layers:(e8c1622f-42a3-4ba0-8ef1-1e2de6870681:(columnOrder:!(f10f4111-3d25-4361-931d-6cd1cc13c13a,'332a8c1a-3d17-408a-9fed-00e874fe75c0'),columns:('332a8c1a-3d17-408a-9fed-00e874fe75c0':(dataType:number,isBucketed:!f,label:'Count%20of%20records',operationType:count,params:(emptyAsNull:!t),scale:ratio,sourceField:___records___),f10f4111-3d25-4361-931d-6cd1cc13c13a:(dataType:string,isBucketed:!t,label:'Top%205%20values%20of%20geo.dest',operationType:terms,params:(exclude:!(),excludeIsRegex:!f,include:!(),includeIsRegex:!f,missingBucket:!f,orderBy:(columnId:'332a8c1a-3d17-408a-9fed-00e874fe75c0',type:column),orderDirection:desc,otherBucket:!t,parentFormat:(id:terms),size:5),scale:ordinal,sourceField:geo.dest)),incompleteColumns:(),sampling:1))),indexpattern:(layers:()),textBased:(layers:())),filters:!(),internalReferences:!(),query:(language:kuery,query:''),visualization:(axisTitlesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),fittingFunction:Linear,gridlinesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),labelsOrientation:(x:0,yLeft:0,yRight:0),layers:!((accessors:!('332a8c1a-3d17-408a-9fed-00e874fe75c0'),colorMapping:(assignments:!(),colorMode:(type:categorical),paletteId:default,specialAssignments:!((color:(type:loop),rule:(type:other),touched:!f))),layerId:e8c1622f-42a3-4ba0-8ef1-1e2de6870681,layerType:data,position:top,seriesType:bar_stacked,showGridlines:!f,xAccessor:f10f4111-3d25-4361-931d-6cd1cc13c13a)),legend:(isVisible:!t,position:right),preferredSeriesType:bar_stacked,tickLabelsVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),valueLabels:hide)),title:'',type:lens,visualizationType:lnsXY),enhancements:(dynamicActions:(events:!())),filters:!(),query:(language:kuery,query:''),searchSessionId:de087e77-1e0b-4dc7-a7c6-c5a75a51e958,syncColors:!f,syncCursor:!t,syncTooltips:!f),panelIndex:'82fedfe7-5e35-4577-8341-f96aec301d45',type:lens))) ``` </details> <details> <summary>v9.2</summary> - [test-9.2.ndjson.zip](https://github.com/user-attachments/files/26359968/test-9.2.ndjson.zip) - [logs-9.2.ndjson.zip](https://github.com/user-attachments/files/26392129/logs-9.2.ndjson.zip) - URL with saved object ID stored as `id`: ``` &_a=(panels:!((config:(),grid:(h:15,i:bd1472ee-2f4d-43d4-96fe-b8a22ad776f2,w:24,x:20,y:0),type:search,uid:bd1472ee-2f4d-43d4-96fe-b8a22ad776f2)),references:!((id:'90943e30-9a47-11e8-b64d-95841ca0b247',name:'bd1472ee-2f4d-43d4-96fe-b8a22ad776f2:kibanaSavedObjectMeta.searchSourceJSON.index',type:index-pattern),(id:'2f360f30-ea74-11eb-b4c6-3d2afc1cb389',name:'bd1472ee-2f4d-43d4-96fe-b8a22ad776f2:savedObjectRef',type:search)),viewMode:edit) ``` - URL with by value panel: ``` &_a=(panels:!((config:(attributes:(references:!((id:'90943e30-9a47-11e8-b64d-95841ca0b247',name:indexpattern-datasource-layer-548fab7f-bd6e-45eb-b496-344e3d42c910,type:index-pattern)),state:(adHocDataViews:(),datasourceStates:(formBased:(layers:('548fab7f-bd6e-45eb-b496-344e3d42c910':(columnOrder:!(ba3ed766-72d4-41e6-8ae4-90a78ce2009e,'3476cfea-f22b-4c8f-92e3-1a2cc3441759'),columns:('3476cfea-f22b-4c8f-92e3-1a2cc3441759':(dataType:number,isBucketed:!f,label:'Count%20of%20records',operationType:count,params:(emptyAsNull:!t),sourceField:___records___),ba3ed766-72d4-41e6-8ae4-90a78ce2009e:(dataType:string,isBucketed:!t,label:'Top%205%20values%20of%20geo.dest',operationType:terms,params:(exclude:!(),excludeIsRegex:!f,include:!(),includeIsRegex:!f,missingBucket:!f,orderBy:(columnId:'3476cfea-f22b-4c8f-92e3-1a2cc3441759',type:column),orderDirection:desc,otherBucket:!t,parentFormat:(id:terms),size:5),sourceField:geo.dest)),incompleteColumns:(),sampling:1))),indexpattern:(layers:()),textBased:(layers:())),filters:!(),internalReferences:!(),query:(language:kuery,query:''),visualization:(axisTitlesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),fittingFunction:Linear,gridlinesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),labelsOrientation:(x:0,yLeft:0,yRight:0),layers:!((accessors:!('3476cfea-f22b-4c8f-92e3-1a2cc3441759'),colorMapping:(assignments:!(),colorMode:(type:categorical),paletteId:default,specialAssignments:!((color:(type:loop),rules:!((type:other)),touched:!f))),layerId:'548fab7f-bd6e-45eb-b496-344e3d42c910',layerType:data,position:top,seriesType:bar_stacked,showGridlines:!f,xAccessor:ba3ed766-72d4-41e6-8ae4-90a78ce2009e)),legend:(isVisible:!t,position:right),preferredSeriesType:bar_stacked,tickLabelsVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),valueLabels:hide)),title:'',type:lens,version:1,visualizationType:lnsXY),enhancements:(dynamicActions:(events:!())),filters:!(),query:(language:kuery,query:''),syncColors:!f,syncCursor:!t,syncTooltips:!f),grid:(h:15,i:'79dea3c3-d390-4245-90e7-1dd02de7581b',w:24,x:6,y:0),type:lens,uid:'79dea3c3-d390-4245-90e7-1dd02de7581b')),references:!((id:'90943e30-9a47-11e8-b64d-95841ca0b247',name:'79dea3c3-d390-4245-90e7-1dd02de7581b:indexpattern-datasource-layer-548fab7f-bd6e-45eb-b496-344e3d42c910',type:index-pattern)),viewMode:edit) ``` </details> <details> <summary>v9.3</summary> - [test-9.3.ndjson.zip](https://github.com/user-attachments/files/26359979/test-9.3.ndjson.zip) - [logs-9.3.ndjson.zip](https://github.com/user-attachments/files/26392136/logs-9.3.ndjson.zip) - URL with saved object ID stored as `savedObjectId`: ``` &_a=(panels:!((config:(savedObjectId:'2f360f30-ea74-11eb-b4c6-3d2afc1cb389'),grid:(h:15,w:24,x:21,y:0),type:search,uid:cea091cd-f1b2-4aee-be79-1a58477c81b8)),references:!(),viewMode:edit) ``` - URL with by value panel: ``` &_a=(panels:!((config:(attributes:(references:!((id:'90943e30-9a47-11e8-b64d-95841ca0b247',name:indexpattern-datasource-layer-ad3a4fbb-b5bf-459f-b055-c7c8f5b11c45,type:index-pattern)),state:(adHocDataViews:(),datasourceStates:(formBased:(layers:(ad3a4fbb-b5bf-459f-b055-c7c8f5b11c45:(columnOrder:!('6a8615ac-4b1c-4dbd-80a5-c3048473d95b','02301045-44b8-4e50-bf3b-78966b78a4db'),columns:('02301045-44b8-4e50-bf3b-78966b78a4db':(dataType:number,isBucketed:!f,label:'Count%20of%20records',operationType:count,params:(emptyAsNull:!t),sourceField:___records___),'6a8615ac-4b1c-4dbd-80a5-c3048473d95b':(dataType:string,isBucketed:!t,label:'Top%205%20values%20of%20geo.dest',operationType:terms,params:(exclude:!(),excludeIsRegex:!f,include:!(),includeIsRegex:!f,missingBucket:!f,orderBy:(columnId:'02301045-44b8-4e50-bf3b-78966b78a4db',type:column),orderDirection:desc,otherBucket:!t,parentFormat:(id:terms),size:5),sourceField:geo.dest)),incompleteColumns:(),sampling:1))),indexpattern:(layers:()),textBased:(layers:())),filters:!(),internalReferences:!(),query:(language:kuery,query:''),visualization:(axisTitlesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),fittingFunction:Linear,gridlinesVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),labelsOrientation:(x:0,yLeft:0,yRight:0),layers:!((accessors:!('02301045-44b8-4e50-bf3b-78966b78a4db'),colorMapping:(assignments:!(),colorMode:(type:categorical),paletteId:default,specialAssignments:!((color:(type:loop),rules:!((type:other)),touched:!f))),layerId:ad3a4fbb-b5bf-459f-b055-c7c8f5b11c45,layerType:data,position:top,seriesType:bar_stacked,showGridlines:!f,xAccessor:'6a8615ac-4b1c-4dbd-80a5-c3048473d95b')),legend:(isVisible:!t,position:right),preferredSeriesType:bar_stacked,tickLabelsVisibilitySettings:(x:!t,yLeft:!t,yRight:!t),valueLabels:hide)),title:'',type:lens,version:1,visualizationType:lnsXY),enhancements:(dynamicActions:(events:!())),filters:!(),query:(language:kuery,query:''),syncColors:!f,syncCursor:!t,syncTooltips:!f),grid:(h:15,w:24,x:20,y:0),type:lens,uid:'28ec9730-ca36-40b7-ab68-ccb0566628d7')),references:!(),viewMode:edit) ``` </details> For convenience, here are some ZIP files with saved objects from version 8.19 to 9.3: - [LegacySavedObjects.zip](https://github.com/user-attachments/files/26359999/LegacySavedObjects.zip) - [DifferentLogDashboardVersions.zip](https://github.com/user-attachments/files/26392099/DifferentLogDashboardVersions.zip) > [!WARNING] > Controls will error out in the 9.0 Logs dashboard. > This has nothing to do with this PR, and will be resolved by #255878 ### Checklist - [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 - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. --------- Co-authored-by: Marta Bondyra <4283304+mbondyra@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: mbondyra <marta.bondyra@elastic.co>
Summary
Fixes an issue in which legacy controls that stored a
dataViewIdin their state, but did not store adataViewRefNameor have a brokendataViewRefName, would throw anInternal Server Errorby transforming into a control with an emptydata_view_id.Release note: This fix is only applicable to serverless deployments.