Skip to content

Commit

Permalink
handle "null" in "timepicker:quickRanges" migration (#95767)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant authored Apr 6, 2021
1 parent 357c4a5 commit 2745a6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/core/server/ui_settings/saved_objects/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ describe('ui_settings 7.12.0 migrations', () => {
const migrated = migration(doc);
expect(JSON.parse(migrated.attributes['timepicker:quickRanges'])).toEqual([migratedQuickRange]);
});

// https://github.com/elastic/kibana/issues/95616
test('returns doc when "timepicker:quickRanges" is null', () => {
const doc = {
type: 'config',
id: '8.0.0',
attributes: {
buildNum: 9007199254740991,
'timepicker:quickRanges': null,
},
references: [],
updated_at: '2020-06-09T20:18:20.349Z',
migrationVersion: {},
};
const migrated = migration(doc);
expect(migrated).toEqual(doc);
});
});

describe('ui_settings 7.13.0 migrations', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/ui_settings/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const migrations = {
...doc,
...(doc.attributes && {
attributes: Object.keys(doc.attributes).reduce((acc, key) => {
if (key === 'timepicker:quickRanges' && doc.attributes[key].indexOf('section') > -1) {
if (key === 'timepicker:quickRanges' && doc.attributes[key]?.indexOf('section') > -1) {
const ranges = JSON.parse(doc.attributes[key]).map(
({ from, to, display }: { from: string; to: string; display: string }) => {
return {
Expand Down

0 comments on commit 2745a6e

Please sign in to comment.