diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_rule.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_rule.ts index 234ba95de54d6..f16858edf0da0 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_rule.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_rule.ts @@ -15,12 +15,17 @@ import * as i18n from './translations'; * @param id desired Rule ID's (not rule_id) * */ -export const useRule = (id: string) => { +export const useRule = (id: string, showToast = true) => { const { addError } = useAppToasts(); - return useFetchRuleByIdQuery(id, { - onError: (error) => { - addError(error, { title: i18n.RULE_AND_TIMELINE_FETCH_FAILURE }); - }, - }); + return useFetchRuleByIdQuery( + id, + showToast + ? { + onError: (error) => { + addError(error, { title: i18n.RULE_AND_TIMELINE_FETCH_FAILURE }); + }, + } + : undefined + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_rule_with_fallback.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_rule_with_fallback.ts index 6290c4ae6622f..e9004d80a5f0a 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_rule_with_fallback.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_rule_with_fallback.ts @@ -77,7 +77,7 @@ const buildLastAlertQuery = (ruleId: string) => ({ * In that case, try to fetch the latest alert generated by the rule and retrieve the rule data from the alert (fallback). */ export const useRuleWithFallback = (ruleId: string): UseRuleWithFallback => { - const { isLoading: ruleLoading, data: ruleData, error, refetch } = useRule(ruleId); + const { isLoading: ruleLoading, data: ruleData, error, refetch } = useRule(ruleId, false); const { addError } = useAppToasts(); const isExistingRule = !isNotFoundError(error);