phacility/phabricator · warning · PhutilArgumentUsageException
Specify an object to test rules for with "--object".
Error message
Specify an object to test rules for with "--object".
What it means
PhutilArgumentUsageException thrown by HeraldTestManagementWorkflow::execute() (the 'bin/herald test' workflow) when the --object argument is missing or empty. The object monogram is mandatory because the whole workflow dry-runs Herald rules against one concrete object; nothing is looked up before this check.
Source
Thrown at src/applications/herald/management/HeraldTestManagementWorkflow.php:34
array(
'name' => 'object',
'param' => 'object',
'help' => pht('Run rules on this object.'),
),
array(
'name' => 'type',
'param' => 'type',
'help' => pht('Run rules for this content type.'),
),
));
}
public function execute(PhutilArgumentParser $args) {
$viewer = $this->getViewer();
$object_name = $args->getArg('object');
if (!strlen($object_name)) {
throw new PhutilArgumentUsageException(
pht('Specify an object to test rules for with "--object".'));
}
$objects = id(new PhabricatorObjectQuery())
->setViewer($viewer)
->withNames(array($object_name))
->execute();
if (!$objects) {
throw new PhutilArgumentUsageException(
pht(
'Unable to load specified object ("%s").',
$object_name));
}
$object = head($objects);
$adapters = HeraldAdapter::getAllAdapters();
$can_select = array();View on GitHub (pinned to 5720a38cfe)
Solutions
- Pass the object monogram: bin/herald test --object T123 (usually together with --type, e.g. --type maniphest.task).
- In scripts, guard first: OBJECT=${OBJECT:?"--object is required"}.
- Run 'bin/herald help test' to see the accepted arguments.
Example fix
# before bin/herald test --type differential.revision # after bin/herald test --object D456 --type differential.revision
Defensive patterns
Strategy: validation
Validate before calling
$object_name = $args->getArg('object');
if (!strlen($object_name)) {
// print usage with example (bin/herald test --object T123 --type ...)
// and exit before any query runs
} Type guard
function hasObjectArgument(PhutilArgumentParser $args) {
return strlen((string)$args->getArg('object')) > 0;
} Try / catch
try {
(new HeraldTestManagementWorkflow())->execute($args);
} catch (PhutilArgumentUsageException $ex) {
// usage error: echo message + help; safe, side-effect-free retry
exit(2);
} Prevention
- Guard the variable in scripts: OBJECT=${OBJECT:?required}.
- Pair --object with --type from the start; both are practically required.
When it happens
Trigger: Running 'bin/herald test' with no --object flag, or with an empty value because a shell variable expanded to nothing. The strlen() check on getArg('object') fires before PhabricatorObjectQuery runs.
Common situations: Copy-pasting an example command that omitted the flag; scripts passing an unset $OBJECT; assuming --type alone is enough to run rules.
Related errors
- Specify a content type to run rules for. For this object, va
- Specify a rule to edit with "--rule <id|monogram>".
- Use flags to specify at least one edit to apply to the rule
- Specify a commit to extract the diff from.
- Specify an atomizer class with %s.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/44e7ee8dad25ad82.
Report an issue: GitHub.