diff --git a/client/app/pages/alert/components/Criteria.jsx b/client/app/pages/alert/components/Criteria.jsx index 3971499a77..57516fd899 100644 --- a/client/app/pages/alert/components/Criteria.jsx +++ b/client/app/pages/alert/components/Criteria.jsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { head, includes, toString } from 'lodash'; +import { head, includes, toString, isEmpty } from 'lodash'; import Input from 'antd/lib/input'; import Icon from 'antd/lib/icon'; @@ -34,7 +34,7 @@ DisabledInput.propTypes = { }; export default function Criteria({ columnNames, resultValues, alertOptions, onChange, editMode }) { - const columnValue = resultValues && head(resultValues)[alertOptions.column]; + const columnValue = !isEmpty(resultValues) ? head(resultValues)[alertOptions.column] : null; const invalidMessage = (() => { // bail if condition is valid for strings if (includes(VALID_STRING_CONDITIONS, alertOptions.op)) { diff --git a/client/app/pages/alert/components/NotificationTemplate.jsx b/client/app/pages/alert/components/NotificationTemplate.jsx index d3c1178436..31e10bdc12 100644 --- a/client/app/pages/alert/components/NotificationTemplate.jsx +++ b/client/app/pages/alert/components/NotificationTemplate.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { head } from 'lodash'; +import { head, isEmpty, isNull, isUndefined } from 'lodash'; import Mustache from 'mustache'; import { HelpTrigger } from '@/components/HelpTrigger'; @@ -15,7 +15,7 @@ import './NotificationTemplate.less'; function normalizeCustomTemplateData(alert, query, columnNames, resultValues) { - const topValue = resultValues && head(resultValues)[alert.options.column]; + const topValue = !isEmpty(resultValues) ? head(resultValues)[alert.options.column] : null; return { ALERT_STATUS: 'TRIGGERED', @@ -25,7 +25,7 @@ function normalizeCustomTemplateData(alert, query, columnNames, resultValues) { ALERT_URL: `${window.location.origin}/alerts/${alert.id}`, QUERY_NAME: query.name, QUERY_URL: `${window.location.origin}/queries/${query.id}`, - QUERY_RESULT_VALUE: topValue, + QUERY_RESULT_VALUE: isNull(topValue) || isUndefined(topValue) ? 'UNKNOWN' : topValue, QUERY_RESULT_ROWS: resultValues, QUERY_RESULT_COLS: columnNames, };