phacility/phabricator · warning · PhutilArgumentUsageException

Specify a content type to run rules for. The specified conte

Error message

Specify a content type to run rules for. The specified content type ("%s") is not valid. For this object, valid content types are: %s.

What it means

Usage error thrown by 'bin/herald test --object <object> --type <type>'. The workflow builds $can_select from Herald adapters that both apply to the object (isTestAdapterForObject) and support dry runs (canCreateTestAdapterForObject). The given --type matched no adapter key at all -- it is not even in $display_adapters -- so it can never be tested, and the message lists every valid key.

Source

Thrown at src/applications/herald/management/HeraldTestManagementWorkflow.php:82

      if ($adapter->canCreateTestAdapterForObject($object)) {
        $can_select[$key] = $adapter;
      }
    }


    $content_type = $args->getArg('type');
    if (!strlen($content_type)) {
      throw new PhutilArgumentUsageException(
        pht(
          'Specify a content type to run rules for. For this object, valid '.
          'content types are: %s.',
          implode(', ', array_keys($can_select))));
    }

    if (!isset($can_select[$content_type])) {
      if (!isset($display_adapters[$content_type])) {
        throw new PhutilArgumentUsageException(
          pht(
            'Specify a content type to run rules for. The specified content '.
            'type ("%s") is not valid. For this object, valid content types '.
            'are: %s.',
            $content_type,
            implode(', ', array_keys($can_select))));
      } else {
        throw new PhutilArgumentUsageException(
          pht(
            'The specified content type ("%s") does not support dry runs. '.
            'Choose a testable content type. For this object, valid content '.
            'types are: %s.',
            $content_type,
            implode(', ', array_keys($can_select))));
      }
    }

    $adapter = $can_select[$content_type]->newTestAdapter(

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Re-run with one of the content types listed verbatim in the error message, e.g. 'bin/herald test --object T123 --type TASK'.
  2. Run 'bin/herald test --object <object>' with no --type to have the command print the valid content type list.
  3. Verify the --object monogram resolves to the object kind you expect; the selectable adapter set is derived from it.
  4. If you are scripting this, resolve the key from HeraldAdapter::getAllAdapters() instead of hardcoding it.

Example fix

// before
./bin/herald test --object T123 --type taks
// after
./bin/herald test --object T123 --type TASK
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking bin/herald test, confirm the type is selectable for the object:
$adapters = HeraldAdapter::getAllAdapters();
$can_select = array();
foreach ($adapters as $key => $adapter) {
  if (!$adapter->isTestAdapterForObject($object)) { continue; }
  if (!$adapter->isAvailableToUser($viewer)) { continue; }
  if ($adapter->canCreateTestAdapterForObject($object)) {
    $can_select[$key] = $adapter;
  }
}
if (!isset($can_select[$type])) {
  throw new InvalidArgumentException(
    'Invalid --type; valid: '.implode(', ', array_keys($can_select)));
}

Type guard

function isSelectableHeraldContentType($object, $viewer, $type) {
  $adapters = HeraldAdapter::getAllAdapters();
  return isset($adapters[$type])
    && $adapters[$type]->isTestAdapterForObject($object)
    && $adapters[$type]->isAvailableToUser($viewer)
    && $adapters[$type]->canCreateTestAdapterForObject($object);
}

Prevention

When it happens

Trigger: Running 'bin/herald test --object T123 --type taks' (typo), or passing a value that is not a Herald adapter content-type key (e.g. --type wiki when no such adapter exists for the object). Matching is exact and case-sensitive against adapter keys like TASK, DREV, CMIT.

Common situations: Typos in --type; scripts written against a different Phabricator version where adapter keys differ; testing an object whose applicable adapters are all display-only; assuming the flag is case-insensitive.

Related errors


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