phacility/phabricator · warning · PhutilArgumentUsageException

No such user '%s' exists.

Error message

No such user '%s' exists.

What it means

Thrown by `bin/mail send-test` when `--from` names a user that PhabricatorPeopleQuery::withUsernames() cannot resolve for the workflow's viewer. The lookup is an exact, case-sensitive match on the username column, so a typo, a wrong case, a nonexistent user, or a user invisible to the viewer all produce this exception. It is a PhutilArgumentUsageException raised before the mail is built.

Source

Thrown at src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php:97

    }

    $type_map = PhabricatorMailExternalMessage::getAllMessageTypes();
    if (!isset($type_map[$type])) {
      throw new PhutilArgumentUsageException(
        pht(
          'Message type "%s" is unknown, supported message types are: %s.',
          $type,
          implode(', ', array_keys($type_map))));
    }

    $from = $args->getArg('from');
    if ($from) {
      $user = id(new PhabricatorPeopleQuery())
        ->setViewer($viewer)
        ->withUsernames(array($from))
        ->executeOne();
      if (!$user) {
        throw new PhutilArgumentUsageException(
          pht("No such user '%s' exists.", $from));
      }
      $from = $user;
    }

    $tos = $args->getArg('to');
    $ccs = $args->getArg('cc');

    if (!$tos && !$ccs) {
      throw new PhutilArgumentUsageException(
        pht(
          'Specify one or more users to send a message to with "--to" and/or '.
          '"--cc".'));
    }

    $names = array_merge($tos, $ccs);
    $users = id(new PhabricatorPeopleQuery())
      ->setViewer($viewer)

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Get the exact username from the user's profile URL or the People application and retry.
  2. Omit --from; the test mail is generated without an explicit From actor.
  3. If scripting, verify the username first with a People query (or `bin/user search`) before invoking send-test.

Example fix

// before
$ bin/mail send-test --from alincoln@example.com --to hsimmons
// Exception: No such user 'alincoln@example.com' exists.

// after
$ bin/mail send-test --from alincoln --to hsimmons
Defensive patterns

Strategy: validation

Validate before calling

// Resolve the username with the same query before invoking the workflow:
$user = id(new PhabricatorPeopleQuery())
  ->setViewer(PhabricatorUser::getOmnipotentUser())
  ->withUsernames(array($from))
  ->executeOne();
if (!$user) {
  fwrite(STDERR, "Unknown username: {$from}\n");
  exit(1);
}

Try / catch

try {
  // invoke the workflow
} catch (PhutilArgumentUsageException $ex) {
  // $ex->getMessage() names the failing username
  fwrite(STDERR, $ex->getMessage()."\n");
  exit(1);
}

Prevention

When it happens

Trigger: `--from alincoln` when no user with that exact username exists; passing a real name ('Abraham Lincoln') or an email address instead of a username; running the workflow with a viewer whose policy filters hide the target user.

Common situations: Copy-pasting display names from the People application instead of usernames; renamed or deleted accounts; installations where usernames differ from the email local part.

Related errors


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