{"record":{"id":"efc29918e57499c5","repo":"grafana/grafana","slug":"duplicate-receiver-name-receiver-name","errorCode":null,"errorMessage":"Duplicate receiver name ${receiver.name}","messagePattern":"Duplicate receiver name (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"public/app/features/alerting/unified/reducers/alertmanager/receivers.ts","lineNumber":56,"sourceCode":"    .addCase(updateReceiverAction, (draft, { payload }) => {\n      const { name, receiver } = payload;\n      const renaming = name !== receiver.name;\n\n      const receivers = draft.alertmanager_config.receivers ?? [];\n\n      const targetIndex = receivers.findIndex((receiver) => receiver.name === name);\n      const targetExists = targetIndex > -1;\n\n      // check if the receiver we want to update exists\n      if (!targetExists) {\n        throw new Error(`Expected receiver ${name} to exist, but did not find it in the config`);\n      }\n\n      // check if the new name doesn't already exist\n      if (renaming) {\n        const nameExists = receivers.some((oldReceiver) => oldReceiver.name === receiver.name);\n        if (nameExists) {\n          throw new Error(`Duplicate receiver name ${receiver.name}`);\n        }\n      }\n\n      // overwrite the receiver with the new one\n      receivers[targetIndex] = receiver;\n\n      // check if we need to update routes if the contact point was renamed\n      const routeTree = draft.alertmanager_config.route;\n\n      if (routeTree && renaming) {\n        draft.alertmanager_config.route = renameReceiverInRoute(routeTree, name, receiver.name);\n      }\n    })\n    // delete a receiver from the alertmanager configuration\n    .addCase(deleteReceiverAction, (draft, { payload: name }) => {\n      remove(draft.alertmanager_config.receivers ?? [], (receiver) => receiver.name === name);\n    });\n});","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/grafana/grafana/blob/ae3104e3690e28e72c8f0c97efc12647a70f75c3/public/app/features/alerting/unified/reducers/alertmanager/receivers.ts#L38-L74","documentation":"Thrown by updateReceiverAction when renaming a contact point (name !== receiver.name) and the new name collides with another existing receiver. The check runs only when renaming, after verifying the target receiver exists. It preserves uniqueness that Alertmanager itself would otherwise reject upstream.","triggerScenarios":"Editing a contact point, changing its name to one already used by a different receiver, then saving. Dispatching updateReceiverAction where renaming === true and receivers.some(r => r.name === receiver.name).","commonSituations":"Renaming a contact point onto another's name to merge them; stale config hiding a recent creation; UI failing to surface the conflict before submit.","solutions":["Choose a unique new name when renaming a contact point.","Refresh the contact points list, then re-validate the chosen name.","If merging was the intent, delete or rename the colliding receiver first.","In tests, ensure no other receiver holds the destination name."],"exampleFix":"// before\ndispatch(updateReceiverAction({ name, receiver }));\n// after\nif (name !== receiver.name && receivers.some((r) => r.name === receiver.name)) {\n  setError('name', { message: 'Another contact point already uses this name' });\n  return;\n}\ndispatch(updateReceiverAction({ name, receiver }));","handlingStrategy":"validation","validationCode":"if (name !== receiver.name && receivers.some((r) => r.name === receiver.name)) {\n  setError('name', 'Another contact point already uses this name');\n  return;\n}","typeGuard":"const isUniqueRename = (receivers, oldName, newName): boolean =>\n  oldName === newName || !receivers.some((r) => r.name === newName);","tryCatchPattern":"try {\n  dispatch(updateReceiverAction({ name, receiver }));\n} catch (e) {\n  if (/Duplicate receiver name/.test(String(e))) {\n    setError('name', e.message);\n  } else { throw e; }\n}","preventionTips":["Check the destination name does not exist before renaming.","Refresh the list before submitting renames.","Disable Save until the new name is unique."],"tags":["redux","alerting","receivers","contact-points","validation"],"backgroundTag":null,"analyzedSha":"ae3104e3690e28e72c8f0c97efc12647a70f75c3","analyzedAt":"2026-08-12T12:48:38.752Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}