diff --git a/public/app/features/alerting/unified/components/AlertRuleDrawerForm.tsx b/public/app/features/alerting/unified/components/AlertRuleDrawerForm.tsx index 6832c8a4aa5..e53438534d8 100644 --- a/public/app/features/alerting/unified/components/AlertRuleDrawerForm.tsx +++ b/public/app/features/alerting/unified/components/AlertRuleDrawerForm.tsx @@ -93,11 +93,18 @@ export function AlertRuleDrawerForm({ const dto = formValuesToRulerGrafanaRuleDTO(effectiveValues); const groupIdentifier = getRuleGroupLocationFromFormValues(effectiveValues); const result = await addRuleToRuleGroup.execute(groupIdentifier, dto, effectiveValues.evaluateEvery); + if (isGrafanaGroupUpdatedResponse(result)) { onClose(); return; } - notifyApp.error('Failed to create rule', 'The rule was not created. Please review the form and try again.'); + + // Check if result has an error message + if (result && typeof result === 'object' && 'error' in result) { + notifyApp.error('Failed to create rule', String(result.error)); + } else { + notifyApp.error('Failed to create rule', 'Please review the form and try again.'); + } } catch (err) { const errorMessage = getMessageFromError(err); notifyApp.error('Failed to create rule', errorMessage); @@ -117,7 +124,7 @@ export function AlertRuleDrawerForm({