phacility/phabricator · warning · PhutilArgumentUsageException

Specify a positive number of days to retain data for.

Error message

Specify a positive number of days to retain data for.

What it means

After accepting --days, the workflow casts the value to int and requires it to be at least 1; zero or negative values throw this usage exception. The guard prevents configuring a collector with a nonsensical retention window of zero or fewer days.

Source

Thrown at src/infrastructure/daemon/garbagecollector/management/PhabricatorGarbageCollectorManagementSetPolicyWorkflow.php:85

          '--days',
          '--indefinite',
          '--default'));
    }

    if ($count > 1) {
      throw new PhutilArgumentUsageException(
        pht(
          'Options "%s", "%s" and "%s" represent mutually exclusive ways '.
          'to choose a policy. Specify only one.',
          '--days',
          '--indefinite',
          '--default'));
    }

    if ($days !== null) {
      $days = (int)$days;
      if ($days < 1) {
        throw new PhutilArgumentUsageException(
          pht(
            'Specify a positive number of days to retain data for.'));
      }
    }

    $collector_const = $collector->getCollectorConstant();
    $value = PhabricatorEnv::getEnvConfig($config_key);

    if ($days !== null) {
      echo tsprintf(
        "%s\n",
        pht(
          'Setting retention policy for "%s" to %s day(s).',
          $collector->getCollectorName(),
          new PhutilNumber($days)));

      $value[$collector_const] = phutil_units($days.' days in seconds');
    } else if ($indefinite) {

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Use --days 1 or greater.
  2. To purge immediately, run the collect workflow rather than setting a zero-day retention policy.
  3. Check the arithmetic that produces the day count in scripts.

Example fix

# before
bin/garbagecollector set-policy --collector <collector> --days 0
# after
bin/garbagecollector set-policy --collector <collector> --days 1
Defensive patterns

Strategy: validation

Validate before calling

if ($days !== null && (int)$days < 1) {
  // reject before running: --days must be a positive integer
}

Prevention

When it happens

Trigger: bin/garbagecollector set-policy --collector <const> --days 0, a negative number, or a string that casts to <= 0.

Common situations: Automation computing a day count from a date delta that evaluates to 0; operators trying to express 'delete everything now' via --days 0 instead of running the collector.

Related errors


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