From 57db24a90d5f064b1658df73c7490426d6f19733 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 24 Jan 2020 13:50:49 +0100 Subject: [PATCH 1/3] Catch exception when refreshing fields of an indexpattern - Condition: Indexpattern without indices and a refresh of fields is triggered - this caused an empty discover screen - and you couldn't remove the index pattern in management --- .../index_patterns/index_patterns/index_pattern.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts index e3482dd483035..f45efbaf3d90f 100644 --- a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts +++ b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts @@ -153,11 +153,17 @@ export class IndexPattern implements IIndexPattern { if (!this.id) { return; } - - if (forceFieldRefresh || this.isFieldRefreshRequired()) { - await this.refreshFields(); + try { + if (forceFieldRefresh || this.isFieldRefreshRequired()) { + await this.refreshFields(); + } + } catch (e) { + // eslint-disable-next-line no-console + console.error(`Refreshing fields of index pattern ${this.id} failed`, { + forceFieldRefresh, + fields: this.fields, + }); } - this.initFields(); } From 659df28f84255ec4474415b72e892f6e471e9aa0 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 27 Jan 2020 08:39:03 +0100 Subject: [PATCH 2/3] Improve solution by refactoring refreshFields --- .../index_patterns/index_pattern.ts | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts index f45efbaf3d90f..d55ea9fbd6b84 100644 --- a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts +++ b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts @@ -153,17 +153,11 @@ export class IndexPattern implements IIndexPattern { if (!this.id) { return; } - try { - if (forceFieldRefresh || this.isFieldRefreshRequired()) { - await this.refreshFields(); - } - } catch (e) { - // eslint-disable-next-line no-console - console.error(`Refreshing fields of index pattern ${this.id} failed`, { - forceFieldRefresh, - fields: this.fields, - }); + + if (forceFieldRefresh || this.isFieldRefreshRequired()) { + await this.refreshFields(); } + this.initFields(); } @@ -498,10 +492,13 @@ export class IndexPattern implements IIndexPattern { toasts.addError(err, { title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', { - defaultMessage: 'Error fetching fields', + defaultMessage: `Error fetching fields for index pattern {title} (ID: {id})`, + values: { + id: this.id, + title: this.title, + }, }), }); - throw err; }); } From dcd0ff95b8b8830947abcc2717397282aec4ff87 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 27 Jan 2020 10:51:48 +0100 Subject: [PATCH 3/3] Fix i18n --- .../data/public/index_patterns/index_patterns/index_pattern.ts | 2 +- x-pack/plugins/translations/translations/ja-JP.json | 3 +-- x-pack/plugins/translations/translations/zh-CN.json | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts index d55ea9fbd6b84..5c09e22b6dbb4 100644 --- a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts +++ b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts @@ -492,7 +492,7 @@ export class IndexPattern implements IIndexPattern { toasts.addError(err, { title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', { - defaultMessage: `Error fetching fields for index pattern {title} (ID: {id})`, + defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})', values: { id: this.id, title: this.title, diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index d1563ff4a0844..b4c85f369519d 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -723,7 +723,6 @@ "data.filter.options.pinAllFiltersButtonLabel": "すべてピン付け", "data.filter.options.unpinAllFiltersButtonLabel": "すべてのピンを外す", "data.filter.searchBar.changeAllFiltersTitle": "すべてのフィルターの変更", - "data.indexPatterns.fetchFieldErrorTitle": "フィールドの取得中にエラーが発生", "data.indexPatterns.unableWriteLabel": "インデックスパターンを書き込めません!このインデックスパターンへの最新の変更を取得するには、ページを更新してください。", "data.indexPatterns.unknownFieldErrorMessage": "インデックスパターン「{title}」のフィールド「{name}」が不明なフィールドタイプを使用しています。", "data.indexPatterns.unknownFieldHeader": "不明なフィールドタイプ {type}", @@ -13205,4 +13204,4 @@ "xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。", "xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。" } -} \ No newline at end of file +} diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 27787a11e43ca..583f181e148c6 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -723,7 +723,6 @@ "data.filter.options.pinAllFiltersButtonLabel": "全部固定", "data.filter.options.unpinAllFiltersButtonLabel": "全部取消固定", "data.filter.searchBar.changeAllFiltersTitle": "更改所有筛选", - "data.indexPatterns.fetchFieldErrorTitle": "提取字段时出错", "data.indexPatterns.unableWriteLabel": "无法写入索引模式!请刷新页面以获取此索引模式的最新更改。", "data.indexPatterns.unknownFieldErrorMessage": "indexPattern “{title}” 中的字段 “{name}” 使用未知字段类型。", "data.indexPatterns.unknownFieldHeader": "未知字段类型 {type}", @@ -13204,4 +13203,4 @@ "xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。", "xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。" } -} \ No newline at end of file +}