phacility/phabricator · error · PhutilArgumentUsageException

Specify a resource type with "--type".

Error message

Specify a resource type with "--type".

What it means

A PhutilArgumentUsageException from `bin/drydock lease` when the --type flag is missing or empty. Every Drydock lease is created against a concrete resource type string (e.g. 'host', 'working-copy') which is later matched against blueprint implementations that can allocate it; without it the lease object cannot be constructed. The check uses phutil_nonempty_string(), so --type '' is rejected too.

Source

Thrown at src/applications/drydock/management/DrydockManagementLeaseWorkflow.php:49

            'param' => 'N',
            'default' => 1,
            'help' => pht('Lease a given number of identical resources.'),
          ),
          array(
            'name' => 'blueprint',
            'param' => 'identifier',
            'repeat' => true,
            'help' => pht('Lease resources from a specific blueprint.'),
          ),
        ));
  }

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

    $resource_type = $args->getArg('type');
    if (!phutil_nonempty_string($resource_type)) {
      throw new PhutilArgumentUsageException(
        pht(
          'Specify a resource type with "--type".'));
    }

    $until = $args->getArg('until');
    if (phutil_nonempty_string($until)) {
      $until = strtotime($until);
      if ($until <= 0) {
        throw new PhutilArgumentUsageException(
          pht(
            'Unable to parse argument to "--until".'));
      }
    }

    $count = $args->getArgAsInteger('count');
    if ($count < 1) {
      throw new PhutilArgumentUsageException(
        pht(

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Pass the resource type: `bin/drydock lease --type host`.
  2. Use the exact type string your blueprints implement ('host', 'working-copy', or a custom type registered by a blueprint implementation).

Example fix

# before
bin/drydock lease --count 2

# after
bin/drydock lease --type host --count 2
Defensive patterns

Strategy: validation

Validate before calling

if (!phutil_nonempty_string($resource_type)) {
  throw new InvalidArgumentException(
    'Resource type is required (e.g. "host", "working-copy").');
}

Type guard

function isKnownResourceType($type) {
  $impls = DrydockBlueprintImplementation::getAllBlueprintImplementations();
  foreach ($impls as $impl) {
    if ($impl->getType() === $type) {
      return true;
    }
  }
  return false;
}

Prevention

When it happens

Trigger: Running `bin/drydock lease` with no flags, or with --attributes/--count but an empty --type value; a script where $RESOURCE_TYPE is unset.

Common situations: First-time use of the CLI without reading the synopsis; shell scripts with unset variables under set -u disabled; renaming a resource type in automation without updating callers.

Related errors


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