{"record":{"id":"f10a7c8a43d9e584","repo":"phacility/phabricator","slug":"specify-which-subscription-to-invoice-with-s","errorCode":null,"errorMessage":"Specify which subscription to invoice with %s.","messagePattern":"Specify which subscription to invoice with (.+?)\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/phortune/management/PhabricatorPhortuneManagementInvoiceWorkflow.php","lineNumber":55,"sourceCode":"            'name' => 'auto-range',\n            'help' => pht('Automatically use the current billing period.'),\n          ),\n          array(\n            'name' => 'force',\n            'help' => pht(\n              'Skip the prompt warning you that this operation is '.\n              'potentially dangerous.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $console = PhutilConsole::getConsole();\n    $viewer = $this->getViewer();\n\n    $subscription_phid = $args->getArg('subscription');\n    if (!$subscription_phid) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify which subscription to invoice with %s.',\n          '--subscription'));\n    }\n\n    $subscription = id(new PhortuneSubscriptionQuery())\n      ->setViewer($viewer)\n      ->withPHIDs(array($subscription_phid))\n      ->needTriggers(true)\n      ->executeOne();\n    if (!$subscription) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Unable to load subscription with PHID \"%s\".',\n          $subscription_phid));\n    }\n\n    $now = $args->getArg('now');","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/phortune/management/PhabricatorPhortuneManagementInvoiceWorkflow.php#L37-L73","documentation":"PhutilArgumentUsageException thrown by the phortune invoice management workflow (bin/phortune invoice) when execute() finds no --subscription argument. Phabricator management workflows use this exception type to abort with a usage message printed to stderr and a non-zero exit code; it signals caller misuse of the CLI, not a system fault. The required value is the PHID of the PhortuneSubscription to invoice.","triggerScenarios":"Running `bin/phortune invoice` with no flags; passing an empty --subscription (getArg('subscription') falsy, e.g. --subscription '' ); or scripting the command while the PHID variable is unset and expands to nothing.","commonSituations":"First-time use of the manual invoicing script during Phortune testing; cron/shell scripts interpolating an empty subscription variable; documentation or runbooks that omit the flag.","solutions":["Add --subscription with the subscription's PHID, copied from the subscription detail page URI/object in the Phortune UI.","If scripting, assert the PHID variable is non-empty (and looks like a PHID) before invoking the command.","Run `bin/phortune help invoice` to confirm the accepted argument names for your Phabricator version."],"exampleFix":"# before\n$ ./bin/phortune invoice\n\n# after\n$ ./bin/phortune invoice --subscription PHID-PSUB-abcdefghijklmnop","handlingStrategy":"validation","validationCode":"// Validate the invocation before shelling out.\nfunction assert_invoice_argv(array $argv) {\n  if (empty($argv['subscription']) || !preg_match('/^PHID-/', $argv['subscription'])) {\n    fwrite(STDERR, \"usage: phortune invoice --subscription <PHID> [--auto-range | --last E --next E] [--force]\\n\");\n    exit(64); // EX_USAGE\n  }\n}","typeGuard":null,"tryCatchPattern":"// PhutilArgumentUsageException prints its message and exits non-zero;\n// when invoking from PHP, capture stderr + exit code instead of letting output vanish.\n$err = exec(sprintf(\n  '%s --subscription %s',\n  escapeshellarg($bin),\n  escapeshellarg($phid)),\n  $output,\n  $exit_code);\nif ($exit_code !== 0) {\n  throw new RuntimeException('phortune invoice failed: '.implode(\"\\n\", $output));\n}","preventionTips":["Always script the full flag set; never interpolate possibly-empty variables into the command.","Copy subscription PHIDs from the subscription detail page, not from memory or old tickets.","Check `bin/phortune help invoice` after upgrading — workflow flags change between versions."],"tags":["php","phabricator","phortune","cli","usage-error","billing"],"backgroundTag":"missing-cli-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}