phacility/phabricator · warning · PhutilArgumentUsageException

Specified "--count" must be larger than 0.

Error message

Specified "--count" must be larger than 0.

What it means

Usage error from 'bin/herald call-webhook' when --count is explicitly supplied as zero or negative. The count defaults to 1 when omitted, but any provided value must be larger than 0 because it drives how many test calls the workflow makes.

Source

Thrown at src/applications/herald/management/HeraldWebhookCallManagementWorkflow.php:61

  }

  public function execute(PhutilArgumentParser $args) {
    $viewer = $this->getViewer();

    $id = $args->getArg('id');
    if (!$id) {
      throw new PhutilArgumentUsageException(
        pht(
          'Specify a webhook to call with "--id".'));
    }

    $count = $args->getArg('count');
    if ($count === null) {
      $count = 1;
    }

    if ($count <= 0) {
      throw new PhutilArgumentUsageException(
        pht(
          'Specified "--count" must be larger than 0.'));
    }

    $hook = id(new HeraldWebhookQuery())
      ->setViewer($viewer)
      ->withIDs(array($id))
      ->executeOne();
    if (!$hook) {
      throw new PhutilArgumentUsageException(
        pht(
          'Unable to load specified webhook ("%s").',
          $id));
    }

    $object_name = $args->getArg('object');
    if ($object_name === null) {
      $object = $hook;

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Omit --count entirely when you want a single call (default 1).
  2. Pass a positive integer, e.g. '--count 5'.
  3. In scripts, guard the value: only emit --count when it is > 0.

Example fix

// before
./bin/herald call-webhook --id 3 --count 0
// after
./bin/herald call-webhook --id 3 --count 1
Defensive patterns

Strategy: validation

Validate before calling

// Only emit --count when it is a positive integer:
$args = array('./bin/herald', 'call-webhook', '--id', (string)$hook_id);
if ($count !== null && $count > 0) {
  $args[] = '--count';
  $args[] = (string)(int)$count;
}

Prevention

When it happens

Trigger: Running './bin/herald call-webhook --id 3 --count 0' or '--count -1'; a script computing --count from a variable that evaluated to 0 (e.g. an empty result set).

Common situations: Automation that derives the count from query results or a loop bound; shell scripts where an unset variable expands to 0.

Related errors


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