phacility/phabricator · error · Exception

Failed to load a random user. You may need to generate more

Error message

Failed to load a random user. You may need to generate more test users first.

What it means

Lipsum (fake data) generators attach a random author to each generated object; loadRandomPHID(new PhabricatorUser()) found no user PHID (or the load failed), so no test author could be chosen. On any normal install this means the database has no users yet to pick from -- typical of a fresh install where data generators ran before user generation.

Source

Thrown at src/applications/lipsum/generator/PhabricatorTestDataGenerator.php:53

    return $row['phid'];
  }

  protected function loadRandomUser() {
    $viewer = $this->getViewer();

    $user_phid = $this->loadRandomPHID(new PhabricatorUser());

    $user = null;
    if ($user_phid) {
      $user = id(new PhabricatorPeopleQuery())
        ->setViewer($viewer)
        ->withPHIDs(array($user_phid))
        ->needUserSettings(true)
        ->executeOne();
    }

    if (!$user) {
      throw new Exception(
        pht(
          'Failed to load a random user. You may need to generate more '.
          'test users first.'));
    }

    return $user;
  }

  protected function getLipsumContentSource() {
    return PhabricatorContentSource::newForSource(
      PhabricatorLipsumContentSource::SOURCECONST);
  }

  /**
   * Roll `n` dice with `d` sides each, then add `bonus` and return the sum.
   */
  protected function roll($n, $d, $bonus = 0) {
    $sum = 0;

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Generate users first: './bin/lipsum generate users' (the users generator key is 'users').
  2. Or create at least one real account, then re-run the original generator.
  3. Script installs to always generate users before content generators.

Example fix

// before
./bin/lipsum generate tasks
// after
./bin/lipsum generate users && ./bin/lipsum generate tasks
Defensive patterns

Strategy: validation

Validate before calling

// Ensure at least one user exists before running object generators:
$count = id(new PhabricatorPeopleQuery())
  ->setViewer(PhabricatorUser::getOmnipotentUser())
  ->execute();
if (!count($count)) {
  phutil_passthru('%s generate users', './bin/lipsum');
}

Prevention

When it happens

Trigger: Running './bin/lipsum generate tasks' (or any object generator needing an author) on a database with zero or no loadable users.

Common situations: Fresh development install where lipsum is run before users exist; a pruned/reset database; test fixtures generated against an empty DB.

Related errors


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