phacility/phabricator · warning · PhutilArgumentUsageException
Specify a content type to run rules for. For this object, va
Error message
Specify a content type to run rules for. For this object, valid content types are: %s.
What it means
PhutilArgumentUsageException thrown by HeraldTestManagementWorkflow when --type is missing. For the given object the workflow first computes $can_select — adapters where canCreateTestAdapterForObject($object) is true — and the error helpfully lists exactly those content-type keys, so the message doubles as discovery for valid values. A --type is mandatory because one object can be seen by several adapters.
Source
Thrown at src/applications/herald/management/HeraldTestManagementWorkflow.php:73
if (!$adapter->isTestAdapterForObject($object)) {
continue;
}
if (!$adapter->isAvailableToUser($viewer)) {
continue;
}
$display_adapters[$key] = $adapter;
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(View on GitHub (pinned to 5720a38cfe)
Solutions
- Re-run with --type set to one of the keys printed inside the error message itself: bin/herald test --object T123 --type maniphest.task.
- Use the fully-qualified adapter key (application.object, e.g. differential.revision, maniphest.task), not a friendly name.
- If the message lists no types, the object cannot be dry-run tested — pick a different object or enable the relevant application.
Example fix
# before bin/herald test --object T123 # after bin/herald test --object T123 --type maniphest.task
Defensive patterns
Strategy: validation
Validate before calling
// Enumerate selectable types for the object, then require one
$can_select = array();
foreach (HeraldAdapter::getAllAdapters() as $key => $adapter) {
if ($adapter->canCreateTestAdapterForObject($object)) {
$can_select[$key] = $adapter;
}
}
if (!strlen($args->getArg('type')) || !isset($can_select[$args->getArg('type')])) {
// print the valid keys: implode(', ', array_keys($can_select))
} Type guard
function isSelectableHeraldContentType($object, $type) {
foreach (HeraldAdapter::getAllAdapters() as $key => $adapter) {
if ($key === $type && $adapter->canCreateTestAdapterForObject($object)) {
return true;
}
}
return false;
} Try / catch
try {
(new HeraldTestManagementWorkflow())->execute($args);
} catch (PhutilArgumentUsageException $ex) {
// the message itself lists valid content types; re-run with one of them
} Prevention
- Use fully-qualified adapter keys ('maniphest.task', 'differential.revision'), not friendly names.
- Parse the valid-type list out of this error when scripting; it is authoritative per object.
When it happens
Trigger: Running 'bin/herald test --object T123' without --type. The strlen() check on getArg('type') fires after adapters are enumerated for the object, and implode(', ', array_keys($can_select)) shows the accepted keys (e.g. 'maniphest.task'). If the listed set is empty, no adapter can create a test for that object at all.
Common situations: Users assume the tool infers the content type from the monogram; first-time users don't know the adapter key strings; the follow-up error (content type not valid / can't create adapter) hits those who guess a key like 'task' instead of 'maniphest.task'.
Related errors
- Specify an object to test rules for with "--object".
- Specify a rule to edit with "--rule <id|monogram>".
- Use flags to specify at least one edit to apply to the rule
- The specified content type ("%s") does not support dry runs.
- Specify a commit to extract the diff from.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/bfee588af0623355.
Report an issue: GitHub.