{"record":{"id":"6bc90eace8fef240","repo":"phacility/phabricator","slug":"unable-to-load-herald-rule-with-id-or-monogram-s","errorCode":null,"errorMessage":"Unable to load Herald rule with ID or monogram \"%s\".","messagePattern":"Unable to load Herald rule with ID or monogram \"(.+?)\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/herald/management/HeraldRuleManagementWorkflow.php","lineNumber":52,"sourceCode":"\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));\n    }\n\n    $is_disable = $args->getArg('disable');\n    $is_enable = $args->getArg('enable');\n\n    $xactions = array();\n\n    if ($is_disable && $is_enable) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify \"--enable\" or \"--disable\", but not both.'));\n    } else if ($is_disable || $is_enable) {\n      $xactions[] = $rule->getApplicationTransactionTemplate()\n        ->setTransactionType(HeraldRuleDisableTransaction::TRANSACTIONTYPE)\n        ->setNewValue($is_disable);","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/herald/management/HeraldRuleManagementWorkflow.php#L34-L70","documentation":"PhutilArgumentUsageException thrown by HeraldRuleManagementWorkflow when the --rule value (after stripping an 'H' monogram prefix) does not resolve to any HeraldRule via HeraldRuleQuery executed by the script's admin viewer. Either no rule with that ID exists, or the viewer cannot see it (though management workflows typically run with omnipotent/admin access, policy or a truly nonexistent ID still yields no result).","triggerScenarios":"Running 'bin/herald rule --rule H9999' where rule 9999 does not exist; passing a name instead of an ID/monogram (e.g. --rule 'My Rule' — only '^H\\d+' monograms and raw numeric IDs are handled); passing an ID from a different install/database; typos in the monogram.","commonSituations":"Operators copy a rule monogram from an old email/notification for a rule that was deleted; run the command against the wrong environment/database; or assume the tool accepts rule names. Note the workflow only special-cases monograms matching /^H\\d+/ — anything else is fed raw to withIDs(), so 'T123' or 'herald-rule-3' never match.","solutions":["Confirm the rule exists and copy its exact monogram from the UI (H + digits), e.g. bin/herald rule --rule H42.","If you only have a name, find the ID first from the rule list page (/herald/) or via 'H' monogram search, then re-run.","Check you are on the correct environment/database — IDs are per-install.","Remember names are not accepted: only 'H<id>' monograms or bare numeric IDs."],"exampleFix":"# before\nbin/herald rule --rule \"Close on review\" --disable\n\n# after\nbin/herald rule --rule H57 --disable","handlingStrategy":"validation","validationCode":"// Resolve the rule exactly like the workflow, before editing\n$rule_id = preg_match('/^H\\d+/', $name) ? substr($name, 1) : $name;\n$rule = id(new HeraldRuleQuery())\n  ->setViewer($viewer)\n  ->withIDs(array($rule_id))\n  ->executeOne();\nif (!$rule) {\n  // friendly error listing available rule IDs, instead of an exception\n}","typeGuard":"function isHeraldRuleMonogram($s) {\n  return is_string($s) && preg_match('/^H\\d+$/', $s) === 1;\n}","tryCatchPattern":"try {\n  (new HeraldRuleManagementWorkflow())->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  if (strpos($ex->getMessage(), 'Unable to load Herald rule') !== false) {\n    // list candidate rules (herald rule query / web UI) and re-prompt\n  }\n}","preventionTips":["Always pass the H-monogram copied from the rule URL; names are not accepted.","In automation, resolve the rule ID once and assert it exists before composing the edit command."],"tags":["herald","phabricator","cli","rule-not-found","monogram"],"backgroundTag":"object-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}