{"record":{"id":"44e7ee8dad25ad82","repo":"phacility/phabricator","slug":"specify-an-object-to-test-rules-for-with-object","errorCode":null,"errorMessage":"Specify an object to test rules for with \"--object\".","messagePattern":"Specify an object to test rules for with \"--object\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/herald/management/HeraldTestManagementWorkflow.php","lineNumber":34,"sourceCode":"          array(\n            'name' => 'object',\n            'param' => 'object',\n            'help' => pht('Run rules on this object.'),\n          ),\n          array(\n            'name' => 'type',\n            'param' => 'type',\n            'help' => pht('Run rules for this content type.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $object_name = $args->getArg('object');\n    if (!strlen($object_name)) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify an object to test rules for with \"--object\".'));\n    }\n\n    $objects = id(new PhabricatorObjectQuery())\n      ->setViewer($viewer)\n      ->withNames(array($object_name))\n      ->execute();\n    if (!$objects) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Unable to load specified object (\"%s\").',\n          $object_name));\n    }\n    $object = head($objects);\n\n    $adapters = HeraldAdapter::getAllAdapters();\n\n    $can_select = array();","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/herald/management/HeraldTestManagementWorkflow.php#L16-L52","documentation":"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.","triggerScenarios":"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.","commonSituations":"Copy-pasting an example command that omitted the flag; scripts passing an unset $OBJECT; assuming --type alone is enough to run rules.","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."],"exampleFix":"# before\nbin/herald test --type differential.revision\n\n# after\nbin/herald test --object D456 --type differential.revision","handlingStrategy":"validation","validationCode":"$object_name = $args->getArg('object');\nif (!strlen($object_name)) {\n  // print usage with example (bin/herald test --object T123 --type ...)\n  // and exit before any query runs\n}","typeGuard":"function hasObjectArgument(PhutilArgumentParser $args) {\n  return strlen((string)$args->getArg('object')) > 0;\n}","tryCatchPattern":"try {\n  (new HeraldTestManagementWorkflow())->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // usage error: echo message + help; safe, side-effect-free retry\n  exit(2);\n}","preventionTips":["Guard the variable in scripts: OBJECT=${OBJECT:?required}.","Pair --object with --type from the start; both are practically required."],"tags":["herald","phabricator","cli","usage-error","missing-argument","dry-run"],"backgroundTag":"missing-cli-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}