phacility/phabricator · warning · PhutilArgumentUsageException

Multiple user identifiers (%s) correspond to the same user.

Error message

Multiple user identifiers (%s) correspond to the same user. Identify each user exactly once.

What it means

A PhutilArgumentUsageException from the shared user-resolution helper in PhabricatorManagementWorkflow (used by scripts taking --user). Before resolving identifiers, it builds a reverse map from lowercased username to the identifiers that named it; if one user is reached by more than one distinct identifier in the same invocation, the command aborts so each user is edited exactly once.

Source

Thrown at src/infrastructure/management/PhabricatorManagementWorkflow.php:139

      $users = id(new PhabricatorPeopleQuery())
        ->setViewer($viewer)
        ->withUsernames($usernames)
        ->execute();

      $reverse_map = array();
      foreach ($usernames as $identifier => $username) {
        $username = phutil_utf8_strtolower($username);
        $reverse_map[$username][] = $identifier;
      }

      foreach ($users as $user) {
        $username = $user->getUsername();
        $username = phutil_utf8_strtolower($username);

        $reverse_identifiers = idx($reverse_map, $username, array());

        if (count($reverse_identifiers) > 1) {
          throw new PhutilArgumentUsageException(
            pht(
              'Multiple user identifiers (%s) correspond to the same user. '.
              'Identify each user exactly once.',
              implode(', ', $reverse_identifiers)));
        }

        foreach ($reverse_identifiers as $reverse_identifier) {
          $results[$reverse_identifier][] = $user;
        }
      }
    }

    if ($ids) {
      $users = id(new PhabricatorPeopleQuery())
        ->setViewer($viewer)
        ->withIDs($ids)
        ->execute();

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Remove the duplicate: name each user exactly once per invocation (drop either the @username or PHID form)
  2. Deduplicate your identifier list before building the command: array_unique / sort -u
  3. Normalize identifiers to a single notation (all usernames or all PHIDs) in generating scripts

Example fix

# before
$ bin/user edit --user alincoln --user @alincoln ...

# after
$ bin/user edit --user alincoln ...
Defensive patterns

Strategy: validation

Validate before calling

// Normalize and dedupe identifiers (case-insensitive) before invoking
// a workflow that resolves users.
$usernames = array_map('phutil_utf8_strtolower', $usernames);
$identifiers = array_unique($identifiers);
$usernames = array_unique($usernames);

Try / catch

try { $users = $workflow->selectUsers($users, $identifiers); } catch (PhutilArgumentUsageException $ex) { /* report duplicate, ask user to name each person once */ }

Prevention

When it happens

Trigger: Passing the same person twice in different notations in one command, e.g. --user alincoln --user @alincoln, or --user alincoln --user PHID-USER-xxxx where both resolve to the same username; duplicate entries in a script-generated identifier list.

Common situations: Scripts concatenating username lists and PHID lists without deduplication; batch administration commands where a user appears in two input files.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/b9ea6a87eaebf290. Report an issue: GitHub.