{"record":{"id":"e01854476270a6de","repo":"phacility/phabricator","slug":"specify-a-revision-to-rebuild-changesets-for-with","errorCode":null,"errorMessage":"Specify a revision to rebuild changesets for with \"--revision\".","messagePattern":"Specify a revision to rebuild changesets for with \"--revision\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/differential/management/PhabricatorDifferentialRebuildChangesetsWorkflow.php","lineNumber":26,"sourceCode":"      ->setName('rebuild-changesets')\n      ->setExamples('**rebuild-changesets** --revision __revision__')\n      ->setSynopsis(pht('Rebuild changesets for a revision.'))\n      ->setArguments(\n        array(\n          array(\n            'name' => 'revision',\n            'param' => 'revision',\n            'help' => pht('Revision to rebuild changesets for.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $revision_identifier = $args->getArg('revision');\n    if (!$revision_identifier) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify a revision to rebuild changesets for with \"--revision\".'));\n    }\n\n    $revision = id(new PhabricatorObjectQuery())\n      ->setViewer($viewer)\n      ->withNames(array($revision_identifier))\n      ->executeOne();\n    if ($revision) {\n      if (!($revision instanceof DifferentialRevision)) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'Object \"%s\" specified by \"--revision\" must be a Differential '.\n            'revision.',\n            $revision_identifier));\n      }\n    } else {\n      $revision = id(new DifferentialRevisionQuery())\n        ->setViewer($viewer)","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/management/PhabricatorDifferentialRebuildChangesetsWorkflow.php#L8-L44","documentation":"PhabricatorDifferentialRebuildChangesetsWorkflow (./bin/differential rebuild-changesets) requires the --revision flag to know which revision's changesets to rebuild. Omitting it (or passing an empty value) throws this usage exception before any query runs, because rebuilding every revision is far too expensive to be an implicit default.","triggerScenarios":"Running './bin/differential rebuild-changesets' with no flags; a script passing --revision \"$REV\" with REV empty or unset; quoting that splits the value away from the flag.","commonSituations":"Post-migration maintenance (rebuilding changesets after hunk storage changes) where the operator forgets the one required flag; cron jobs with an unset revision variable.","solutions":["Re-run with the revision: ./bin/differential rebuild-changesets --revision D456","In scripts, guard with: test -n \"$REV\" && ./bin/differential rebuild-changesets --revision \"$REV\"","Fix the step that was supposed to supply the revision identifier"],"exampleFix":"# before\nphabricator/ $ ./bin/differential rebuild-changesets\nUsage Exception: Specify a revision to rebuild changesets for with \"--revision\".\n\n# after\nphabricator/ $ ./bin/differential rebuild-changesets --revision D456","handlingStrategy":"validation","validationCode":"# Require a revision before invoking\n: \"${REV:?--revision D<id> is required}\"\nphabricator/bin/differential rebuild-changesets --revision \"$REV\"","typeGuard":"function isDifferentialMonogram($name) {\n  return is_string($name) && preg_match('/^D\\d+$/', $name);\n}","tryCatchPattern":"try {\n  $workflow->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // Missing --revision: supply it and re-run; nothing was rebuilt.\n}","preventionTips":["Make --revision mandatory in wrapper scripts (fail on empty variable)","Pair rebuild-changesets invocations with the exact revision monogram in runbooks"],"tags":["phabricator","differential","cli","rebuild-changesets","missing-option","usage-error"],"backgroundTag":"cli-usage-error","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}