{"record":{"id":"0a8e1719fea68dc9","repo":"phacility/phabricator","slug":"specify-a-rule-to-edit-with-rule-id-monogram","errorCode":null,"errorMessage":"Specify a rule to edit with \"--rule <id|monogram>\".","messagePattern":"Specify a rule to edit with \"--rule <id\\|monogram>\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/herald/management/HeraldRuleManagementWorkflow.php","lineNumber":37,"sourceCode":"            'help' => pht('Apply changes to this rule.'),\n          ),\n          array(\n            'name' => 'disable',\n            'help' => pht('Disable the rule.'),\n          ),\n          array(\n            'name' => 'enable',\n            'help' => pht('Enable the rule.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $rule_name = $args->getArg('rule');\n    if (!strlen($rule_name)) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify a rule to edit with \"--rule <id|monogram>\".'));\n    }\n\n    if (preg_match('/^H\\d+/', $rule_name)) {\n      $rule_id = substr($rule_name, 1);\n    } else {\n      $rule_id = $rule_name;\n    }\n\n    $rule = id(new HeraldRuleQuery())\n      ->setViewer($viewer)\n      ->withIDs(array($rule_id))\n      ->executeOne();\n    if (!$rule) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Unable to load Herald rule with ID or monogram \"%s\".',\n          $rule_name));","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/herald/management/HeraldRuleManagementWorkflow.php#L19-L55","documentation":"PhutilArgumentUsageException thrown by HeraldRuleManagementWorkflow::execute() (the 'bin/herald rule' workflow) when the --rule argument is missing or empty. This is a usage error printed with the command's help text; nothing has been executed or modified yet.","triggerScenarios":"Running 'bin/herald rule' with no --rule flag at all, or with an empty value ('--rule \"\"). The strlen() check on getArg('rule') fires before any rule lookup happens.","commonSituations":"Copy-pasting the workflow invocation from docs that omit the flag; shell scripts where $RULE is unset and expands to nothing; assuming the tool is interactive and will prompt.","solutions":["Pass the rule ID or monogram explicitly: bin/herald rule --rule H123 (or --rule 123).","In scripts, default and assert the variable first: RULE=${RULE:?\"--rule is required\"}.","Run 'bin/herald help rule' to see all flags before composing the command."],"exampleFix":"# before\nbin/herald rule --disable\n\n# after\nbin/herald rule --rule H123 --disable","handlingStrategy":"validation","validationCode":"$rule_name = $args->getArg('rule');\nif (!strlen($rule_name)) {\n  // print usage and exit non-zero BEFORE execute() proceeds\n  throw new PhutilArgumentUsageException(pht(\n    'Specify a rule to edit with \"--rule <id|monogram>\".'));\n}","typeGuard":"function hasRuleArgument(PhutilArgumentParser $args) {\n  return strlen((string)$args->getArg('rule')) > 0;\n}","tryCatchPattern":"try {\n  (new HeraldRuleManagementWorkflow())->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // usage errors: print message, show help, exit code 2 — safe to retry\n  fwrite(STDERR, $ex->getMessage().\"\\n\");\n  exit(2);\n}","preventionTips":["Wrap bin/herald calls in scripts that assert required variables: RULE=${RULE:?required}.","Check 'bin/herald help rule' when composing commands instead of guessing flags."],"tags":["herald","phabricator","cli","usage-error","missing-argument"],"backgroundTag":"missing-cli-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}