From 8a544eecddb403c27ad6f942fd3fbef418053323 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Mon, 20 Jun 2022 09:57:01 -0400 Subject: [PATCH] [v9.0.x] Alerting: Fix alert rule page crashing when datasource contained URL unsafe characters (#51123) Co-authored-by: Gilles De Mey --- public/app/features/alerting/unified/RuleViewer.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/app/features/alerting/unified/RuleViewer.tsx b/public/app/features/alerting/unified/RuleViewer.tsx index 647795709f7..0ab15ba383a 100644 --- a/public/app/features/alerting/unified/RuleViewer.tsx +++ b/public/app/features/alerting/unified/RuleViewer.tsx @@ -45,9 +45,10 @@ const pageTitle = 'Alerting / View rule'; export function RuleViewer({ match }: RuleViewerProps) { const styles = useStyles2(getStyles); - const { id, sourceName } = match.params; + const { id } = match.params; const identifier = ruleId.tryParse(id, true); - const { loading, error, result: rule } = useCombinedRule(identifier, sourceName); + + const { loading, error, result: rule } = useCombinedRule(identifier, identifier?.ruleSourceName); const runner = useMemo(() => new AlertingQueryRunner(), []); const data = useObservable(runner.get()); const queries2 = useMemo(() => alertRuleToQueries(rule), [rule]); @@ -86,7 +87,7 @@ export function RuleViewer({ match }: RuleViewerProps) { ); }, []); - if (!sourceName) { + if (!identifier?.ruleSourceName) { return ( @@ -96,7 +97,7 @@ export function RuleViewer({ match }: RuleViewerProps) { ); } - const rulesSource = getRulesSourceByName(sourceName); + const rulesSource = getRulesSourceByName(identifier.ruleSourceName); if (loading) { return (