Skip to content

Commit 55f2410

Browse files
committed
Optimize code to avoid undefined exception
Signed-off-by: gaobinlong <gbinlong@amazon.com>
1 parent 49078ac commit 55f2410

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

opensearch_dashboards.json

+1
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
"opensearch-anomaly-detection"
3232
]
3333
}
34+

public/components/DiscoverAction/GenerateAnomalyDetector.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ function GenerateAnomalyDetector({
9999

100100
const dataSourceId = context.indexPattern?.dataSourceRef?.id;
101101
const timeFieldFromIndexPattern = context.indexPattern?.timeFieldName;
102-
const [categoricalFields, dateFields] = context.indexPattern?.fields.reduce(
102+
const fieldsFromContext = context.indexPattern?.fields || [];
103+
const [categoricalFields, dateFields] = fieldsFromContext.reduce(
103104
([cFields, dFields], indexPatternField) => {
104105
const esType = indexPatternField.spec.esTypes?.[0];
105106
const name = indexPatternField.spec.name;

0 commit comments

Comments
 (0)