phacility/phabricator · error · PhutilArgumentUsageException

Specified maximum date must come after specified minimum…

Error message

Specified maximum date must come after specified minimum date.

What it means

Thrown by the audit delete workflow (bin/audit delete) when both --min-commit-date and --max-commit-date are supplied and the minimum is strictly greater than the maximum. Dates are compared as loaded values (loadDate), so an inverted range is rejected before any query runs — protecting you from selecting the wrong set of audit data to delete.

Solutions

  1. Swap the two flags so the earlier date is --min-commit-date and the later is --max-commit-date
  2. Re-run with --dry-run first to see what would be deleted before doing it for real
  3. Use unambiguous absolute dates (YYYY-MM-DD) to avoid parse surprises

Example fix

# before
$ bin/audit delete --min-commit-date 2024-12-01 --max-commit-date 2024-01-01
# after
$ bin/audit delete --min-commit-date 2024-01-01 --max-commit-date 2024-12-01 --dry-run
Defensive patterns

Strategy: validation

Validate before calling

$min = strtotime($args->getArg('min-commit-date'));
$max = strtotime($args->getArg('max-commit-date'));
if ($min !== false && $max !== false && $min > $max) {
  throw new InvalidArgumentException('min-commit-date must be <= max-commit-date');
}

Prevention

When it happens

Trigger: Passing --min-commit-date 2024-12-01 --max-commit-date 2024-01-01 (arguments swapped), or mixing formats so the parsed min lands after max.

Common situations: Copy-pasting a command template and swapping the flags; timezone confusion when using relative or local-time formats around midnight/year boundaries.

Related errors


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

Appendix: source

Thrown at src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php:74

            'param' => 'ids',
            'help' => pht('Select only audits with the given IDs.'),
          ),
        ));
  }

  public function execute(PhutilArgumentParser $args) {
    $viewer = $this->getViewer();
    $users = $this->loadUsers($args->getArg('users'));
    $repos = $this->loadRepos($args->getArg('repositories'));
    $commits = $this->loadCommits($args->getArg('commits'));
    $ids = $this->parseList($args->getArg('ids'));

    $status = $args->getArg('status');

    $min_date = $this->loadDate($args->getArg('min-commit-date'));
    $max_date = $this->loadDate($args->getArg('max-commit-date'));
    if ($min_date && $max_date && ($min_date > $max_date)) {
      throw new PhutilArgumentUsageException(
        pht('Specified maximum date must come after specified minimum date.'));
    }

    $is_dry_run = $args->getArg('dry-run');

    $query = id(new DiffusionCommitQuery())
      ->setViewer($this->getViewer())
      ->needAuditRequests(true);

    if ($status) {
      $query->withStatuses(array($status));
    }

    $id_map = array();
    if ($ids) {
      $id_map = array_fuse($ids);
      $query->withAuditIDs($ids);
    }

View on GitHub (pinned to 5720a38cfe)