Skip to content

Commit

Permalink
Optimize code to avoid undefined exception
Browse files Browse the repository at this point in the history
Signed-off-by: gaobinlong <[email protected]>
  • Loading branch information
gaobinlong committed Aug 27, 2024
1 parent 49078ac commit 55f2410
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@
"opensearch-anomaly-detection"
]
}

3 changes: 2 additions & 1 deletion public/components/DiscoverAction/GenerateAnomalyDetector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ function GenerateAnomalyDetector({

const dataSourceId = context.indexPattern?.dataSourceRef?.id;
const timeFieldFromIndexPattern = context.indexPattern?.timeFieldName;
const [categoricalFields, dateFields] = context.indexPattern?.fields.reduce(
const fieldsFromContext = context.indexPattern?.fields || [];
const [categoricalFields, dateFields] = fieldsFromContext.reduce(
([cFields, dFields], indexPatternField) => {
const esType = indexPatternField.spec.esTypes?.[0];
const name = indexPatternField.spec.name;
Expand Down

0 comments on commit 55f2410

Please sign in to comment.