grafana/grafana · error · Error

Duplicate receiver name ${receiver.name}

Error message

Duplicate receiver name ${receiver.name}

What it means

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.

Source

Thrown at public/app/features/alerting/unified/reducers/alertmanager/receivers.ts:56

    .addCase(updateReceiverAction, (draft, { payload }) => {
      const { name, receiver } = payload;
      const renaming = name !== receiver.name;

      const receivers = draft.alertmanager_config.receivers ?? [];

      const targetIndex = receivers.findIndex((receiver) => receiver.name === name);
      const targetExists = targetIndex > -1;

      // check if the receiver we want to update exists
      if (!targetExists) {
        throw new Error(`Expected receiver ${name} to exist, but did not find it in the config`);
      }

      // check if the new name doesn't already exist
      if (renaming) {
        const nameExists = receivers.some((oldReceiver) => oldReceiver.name === receiver.name);
        if (nameExists) {
          throw new Error(`Duplicate receiver name ${receiver.name}`);
        }
      }

      // overwrite the receiver with the new one
      receivers[targetIndex] = receiver;

      // check if we need to update routes if the contact point was renamed
      const routeTree = draft.alertmanager_config.route;

      if (routeTree && renaming) {
        draft.alertmanager_config.route = renameReceiverInRoute(routeTree, name, receiver.name);
      }
    })
    // delete a receiver from the alertmanager configuration
    .addCase(deleteReceiverAction, (draft, { payload: name }) => {
      remove(draft.alertmanager_config.receivers ?? [], (receiver) => receiver.name === name);
    });
});

View on GitHub (pinned to ae3104e369)

Solutions

  1. Choose a unique new name when renaming a contact point.
  2. Refresh the contact points list, then re-validate the chosen name.
  3. If merging was the intent, delete or rename the colliding receiver first.
  4. In tests, ensure no other receiver holds the destination name.

Example fix

// before
dispatch(updateReceiverAction({ name, receiver }));
// after
if (name !== receiver.name && receivers.some((r) => r.name === receiver.name)) {
  setError('name', { message: 'Another contact point already uses this name' });
  return;
}
dispatch(updateReceiverAction({ name, receiver }));
Defensive patterns

Strategy: validation

Validate before calling

if (name !== receiver.name && receivers.some((r) => r.name === receiver.name)) {
  setError('name', 'Another contact point already uses this name');
  return;
}

Type guard

const isUniqueRename = (receivers, oldName, newName): boolean =>
  oldName === newName || !receivers.some((r) => r.name === newName);

Try / catch

try {
  dispatch(updateReceiverAction({ name, receiver }));
} catch (e) {
  if (/Duplicate receiver name/.test(String(e))) {
    setError('name', e.message);
  } else { throw e; }
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of grafana/grafana@ae3104e369 (2026-08-12). Data as JSON: /api/errors/efc29918e57499c5. Report an issue: GitHub.