{"record":{"id":"1bf12b071da4c3bf","repo":"phacility/phabricator","slug":"specified-count-must-be-larger-than-0","errorCode":null,"errorMessage":"Specified \"--count\" must be larger than 0.","messagePattern":"Specified \"--count\" must be larger than 0\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/herald/management/HeraldWebhookCallManagementWorkflow.php","lineNumber":61,"sourceCode":"  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $id = $args->getArg('id');\n    if (!$id) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify a webhook to call with \"--id\".'));\n    }\n\n    $count = $args->getArg('count');\n    if ($count === null) {\n      $count = 1;\n    }\n\n    if ($count <= 0) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specified \"--count\" must be larger than 0.'));\n    }\n\n    $hook = id(new HeraldWebhookQuery())\n      ->setViewer($viewer)\n      ->withIDs(array($id))\n      ->executeOne();\n    if (!$hook) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Unable to load specified webhook (\"%s\").',\n          $id));\n    }\n\n    $object_name = $args->getArg('object');\n    if ($object_name === null) {\n      $object = $hook;","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/herald/management/HeraldWebhookCallManagementWorkflow.php#L43-L79","documentation":"Usage error from 'bin/herald call-webhook' when --count is explicitly supplied as zero or negative. The count defaults to 1 when omitted, but any provided value must be larger than 0 because it drives how many test calls the workflow makes.","triggerScenarios":"Running './bin/herald call-webhook --id 3 --count 0' or '--count -1'; a script computing --count from a variable that evaluated to 0 (e.g. an empty result set).","commonSituations":"Automation that derives the count from query results or a loop bound; shell scripts where an unset variable expands to 0.","solutions":["Omit --count entirely when you want a single call (default 1).","Pass a positive integer, e.g. '--count 5'.","In scripts, guard the value: only emit --count when it is > 0."],"exampleFix":"// before\n./bin/herald call-webhook --id 3 --count 0\n// after\n./bin/herald call-webhook --id 3 --count 1","handlingStrategy":"validation","validationCode":"// Only emit --count when it is a positive integer:\n$args = array('./bin/herald', 'call-webhook', '--id', (string)$hook_id);\nif ($count !== null && $count > 0) {\n  $args[] = '--count';\n  $args[] = (string)(int)$count;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Coerce user-supplied counts to int and clamp to >= 1 before building the command.","Default to omitting --count when you only need one call."],"tags":["herald","webhook","phabricator","cli","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}