jlcodes99/cockpit-tools · warning

accounts.groups.error.duplicate

accounts.groups.error.duplicate

Error message

accounts.groups.error.duplicate

What it means

The account-group rename handler checks that no OTHER group (group.id !== groupId) already uses the trimmed target name; if one does, it throws an Error with the localized message 'accounts.groups.error.duplicate'. It enforces unique group names within the accounts page.

Source

Thrown at src/pages/AccountsPage.tsx:2904

      })
    })
  };

  const handleAssignAccountsToGroup = async (
    groupId: string,
    groupName: string,
    accountIds: string[]
  ) => {
    const currentGroup = accountGroups.find((group) => group.id === groupId)
    if (!currentGroup) return

    const nextName = groupName.trim()
    if (!nextName) {
      throw new Error(t('platformLayout.groupNameRequired'))
    }

    if (accountGroups.some((group) => group.id !== groupId && group.name === nextName)) {
      throw new Error(t('accounts.groups.error.duplicate'))
    }

    const currentIds = new Set(currentGroup.accountIds)
    const nextIds = new Set(accountIds)
    const addedIds = accountIds.filter((accountId) => !currentIds.has(accountId))
    const removedIds = currentGroup.accountIds.filter((accountId) => !nextIds.has(accountId))
    const shouldRename = nextName !== currentGroup.name

    if (!shouldRename && addedIds.length === 0 && removedIds.length === 0) return

    if (shouldRename) {
      await renameGroup(groupId, nextName)
    }

    if (accountIds.length > 0) {
      await assignAccountsToGroup(groupId, accountIds)
    }

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Choose a group name that is not already used by another group.
  2. Before calling the handler, check accountGroups.some(g => g.id !== groupId && g.name === nextName) and surface a duplicate-name message.
  3. Catch the error in the UI and display the localized duplicate-name message next to the input.

Example fix

// before
await controller.renameGroup(groupId, 'Work');
// after
const nextName = name.trim();
if (accountGroups.some(g => g.id !== groupId && g.name === nextName)) {
  showError(t('accounts.groups.error.duplicate'));
  return;
}
await controller.renameGroup(groupId, nextName);
Defensive patterns

Strategy: validation

Validate before calling

const nextName = groupName.trim();
const isDuplicate = accountGroups.some(g => g.id !== groupId && g.name === nextName);
if (isDuplicate) throw new Error(t('accounts.groups.error.duplicate'));

Try / catch

try {
  await controller.renameGroup(groupId, groupName);
} catch (e) {
  if (e.message === t('accounts.groups.error.duplicate')) {
    showFieldError('groupName', e.message);
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the group rename handler with a nextName that exactly matches the current name of a different account group in accountGroups.

Common situations: User types a name that already exists in the group list; bulk-importing group definitions with repeated names; renaming a group to the name of a previously deleted-but-still-present group.

Related errors


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/e497e64ddc185668. Report an issue: GitHub.