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

[7.3] Fixes #42519 dashboard migration bug (#42520) #42673

Merged
merged 1 commit into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,28 @@ test('6.1 migrates uiState, sort, and scales', async () => {
expect((newPanel.embeddableConfig as any).vis.defaultColors['0+-+100']).toBe('rgb(0,104,55)');
});

// https://github.com/elastic/kibana/issues/42519
it('6.1 migrates when uiState={} and panels have sort / column override', () => {
const uiState = {};
const panels: RawSavedDashboardPanel610[] = [
{
panelIndex: 1,
sort: 'sort',
version: '6.1.0',
name: 'panel-123',
gridData: { h: 3, x: 0, y: 0, w: 6, i: '123' },
},
{
panelIndex: 2,
columns: ['hi'],
version: '6.1.0',
name: 'panel-123',
gridData: { h: 3, x: 0, y: 0, w: 6, i: '123' },
},
];
expect(() => migratePanelsTo730(panels, '8.0.0', true, uiState)).not.toThrow();
});

test('6.2 migrates sort and scales', async () => {
const panels: RawSavedDashboardPanel620[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function migrate610PanelToLatest(
}
});

const embeddableConfig = uiState ? uiState[`P-${panel.panelIndex}`] : {};
const embeddableConfig = uiState ? uiState[`P-${panel.panelIndex}`] || {} : {};

// 2. (6.4) remove columns, sort properties
if (panel.columns || panel.sort) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import { Logger } from 'target/types/server/saved_objects/migrations/core/migration_logger';
import { inspect } from 'util';
import { DashboardDoc730ToLatest, DashboardDoc700To720 } from './types';
import { isDashboardDoc } from './is_dashboard_doc';
import { moveFiltersToQuery } from './move_filters_to_query';
Expand All @@ -43,7 +44,9 @@ export function migrations730(
);
} catch (e) {
logger.warning(
`Exception @ migrations730 while trying to migrate query filters!\nError:${e}\nSearchSource JSON:\n${doc.attributes.kibanaSavedObjectMeta.searchSourceJSON}`
`Exception @ migrations730 while trying to migrate dashboard query filters!\n` +
`${e.stack}\n` +
`dashboard: ${inspect(doc, false, null)}`
);
return doc;
}
Expand All @@ -67,7 +70,11 @@ export function migrations730(

delete doc.attributes.uiStateJSON;
} catch (e) {
logger.warning(`Exception @ migrations730 while trying to migrate dashboard panels! ${e}`);
logger.warning(
`Exception @ migrations730 while trying to migrate dashboard panels!\n` +
`Error: ${e.stack}\n` +
`dashboard: ${inspect(doc, false, null)}`
);
return doc;
}

Expand Down