{"record":{"id":"6a5197f0b4b977ed","repo":"phacility/phabricator","slug":"object-s-specified-by-revision-must-be-a-di","errorCode":null,"errorMessage":"Object \"%s\" specified by \"--revision\" must be a Differential revision.","messagePattern":"Object \"(.+?)\" specified by \"--revision\" must be a Differential revision\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/differential/management/PhabricatorDifferentialRebuildChangesetsWorkflow.php","lineNumber":36,"sourceCode":"        ));\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)\n        ->withIDs(array($revision_identifier))\n        ->executeOne();\n    }\n\n    if (!$revision) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'No revision \"%s\" exists.',\n          $revision_identifier));\n    }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/management/PhabricatorDifferentialRebuildChangesetsWorkflow.php#L18-L54","documentation":"rebuild-changesets resolves --revision first via PhabricatorObjectQuery->withNames(); if that lookup succeeds but the object is not a DifferentialRevision, the workflow throws this usage exception. The check exists because the generic name lookup happily resolves any monogram (tasks, mocks, repositories), but only revisions have rebuildable changesets.","triggerScenarios":"Passing 'T456' (Maniphest task), 'M123' (mock), or another monogram in --revision; scripts templating a numeric ID with the wrong prefix; a name like 'D456' being shadowed by another object alias (rare) — note that if the generic lookup misses, the code falls back to DifferentialRevisionQuery->withIDs(), so a plain numeric ID is also accepted","commonSituations":"Automation that stores a single ticket number and derives both T and D references from it; users pasting a task monogram out of habit; hand-written runbooks mixing up object prefixes.","solutions":["Pass a Differential revision: --revision D<id> (or a bare numeric revision ID, which hits the fallback query)","Fix the source that generated the wrong-prefixed monogram","Validate the argument shape before running: it must match /^D?\\d+$/"],"exampleFix":"# before\nphabricator/ $ ./bin/differential rebuild-changesets --revision T456\nUsage Exception: Object \"T456\" specified by \"--revision\" must be a Differential revision.\n\n# after\nphabricator/ $ ./bin/differential rebuild-changesets --revision D456","handlingStrategy":"validation","validationCode":"// Validate the --revision value shape before running\nif (!preg_match('/^D\\\\d+$|^\\\\d+$/', $revision_identifier)) {\n  throw new Exception('Pass a Differential revision like D123 (or a bare numeric ID).');\n}","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  // 'must be a Differential revision' -> the name resolved to another object;\n  // correct the prefix to D (or use the bare numeric revision ID) and retry.\n}","preventionTips":["Validate monogram prefixes at the tool boundary; only D-monograms (or bare IDs) are valid here","Avoid generating multiple monogram types from one shared ticket number in automation"],"tags":["phabricator","differential","cli","rebuild-changesets","object-type","monogram","usage-error"],"backgroundTag":"invalid-object-type","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}