phacility/phabricator · warning · PhutilArgumentUsageException

Specify the name of exactly one object to show policy…

Error message

Specify the name of exactly one object to show policy information for.

What it means

Usage guard in the policy 'show' CLI workflow: fires when more than one object name was passed. The command displays policy details for exactly one object, so after the first name is accepted any extras abort the run with this arity check.

Solutions

  1. Invoke the command once per object, passing exactly one name each time.

Example fix

# before
./bin/policy show T1 T2
# after
./bin/policy show T1 && ./bin/policy show T2
Defensive patterns

Strategy: validation

Validate before calling

#!/bin/sh
[ "$#" -eq 1 ] || { echo 'pass exactly one object name' >&2; exit 64; }
exec ./bin/policy show "$@"

Prevention

When it happens

Trigger: Running ./bin/policy show T1 T2 with two or more names, often via a shell glob that matched several objects.

Common situations: Globbing monograms in scripts and pasting several names expecting batch output.

Related errors


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

Appendix: source

Thrown at src/applications/policy/management/PhabricatorPolicyManagementShowWorkflow.php:29

      ->setArguments(
        array(
          array(
            'name'      => 'objects',
            'wildcard'  => true,
          ),
        ));
  }

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

    $obj_names = $args->getArg('objects');
    if (!$obj_names) {
      throw new PhutilArgumentUsageException(
        pht('Specify the name of an object to show policy information for.'));
    } else if (count($obj_names) > 1) {
      throw new PhutilArgumentUsageException(
        pht(
          'Specify the name of exactly one object to show policy information '.
          'for.'));
    }

    $object = id(new PhabricatorObjectQuery())
      ->setViewer($viewer)
      ->withNames($obj_names)
      ->executeOne();

    if (!$object) {
      $name = head($obj_names);
      throw new PhutilArgumentUsageException(
        pht(
          "No such object '%s'!",
          $name));
    }

View on GitHub (pinned to 5720a38cfe)