{"record":{"id":"195456aef8b4c8ba","repo":"phacility/phabricator","slug":"revision-s-does-not-exist","errorCode":null,"errorMessage":"Revision \"%s\" does not exist.","messagePattern":"Revision \"(.+?)\" does not exist\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/differential/management/PhabricatorDifferentialAttachCommitWorkflow.php","lineNumber":48,"sourceCode":"    $commit_name = head($argv);\n    $revision_name = last($argv);\n\n    $commit = id(new DiffusionCommitQuery())\n      ->setViewer($viewer)\n      ->withIdentifiers(array($commit_name))\n      ->executeOne();\n    if (!$commit) {\n      throw new PhutilArgumentUsageException(\n        pht('Commit \"%s\" does not exist.', $commit_name));\n    }\n\n    $revision = id(new PhabricatorObjectQuery())\n      ->setViewer($viewer)\n      ->withNames(array($revision_name))\n      ->executeOne();\n\n    if (!$revision) {\n      throw new PhutilArgumentUsageException(\n        pht('Revision \"%s\" does not exist.', $revision_name));\n    }\n\n    if (!($revision instanceof DifferentialRevision)) {\n      throw new PhutilArgumentUsageException(\n        pht('Object \"%s\" must be a Differential revision.', $revision_name));\n    }\n\n    // Reload the revision to get the active diff.\n    $revision = id(new DifferentialRevisionQuery())\n      ->setViewer($viewer)\n      ->withIDs(array($revision->getID()))\n      ->needActiveDiffs(true)\n      ->executeOne();\n\n    $differential_phid = id(new PhabricatorDifferentialApplication())\n      ->getPHID();\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/management/PhabricatorDifferentialAttachCommitWorkflow.php#L30-L66","documentation":"In attach-commit, the second positional argument is resolved with PhabricatorObjectQuery->withNames()->executeOne(); if no object matches the given name, the workflow throws this usage exception. Only names the viewer can see resolve, so an invisible or mistyped revision name is indistinguishable from a nonexistent one.","triggerScenarios":"Passing a bare number ('456') instead of the D-prefixed monogram 'D456'; passing a revision PHID where a name is expected; typo in the monogram; the revision exists but is hidden from the acting user by view policy; passing a URI instead of the monogram.","commonSituations":"Scripts piping raw IDs from another system into the command; new operators unfamiliar with the D-monogram convention; restricted-policy revisions and non-admin CLI users (CLI runs as the console user unless configured otherwise).","solutions":["Use the canonical monogram form D<id> (e.g., D456) as the second argument","Pre-validate the name with './bin/search' or a Conduit 'phid.lookup' call before attaching","If the revision is real but hidden, run as a user who can see it (or an admin)","Check for trailing whitespace or shell mangling of the argument"],"exampleFix":"# before\nphabricator/ $ ./bin/differential attach-commit rP703dcf5 456\nUsage Exception: Revision \"456\" does not exist.\n\n# after\nphabricator/ $ ./bin/differential attach-commit rP703dcf5 D456","handlingStrategy":"validation","validationCode":"// Pre-validate the revision name resolves to a visible revision:\n$result = id(new PhabricatorObjectQuery())\n  ->setViewer($viewer)\n  ->withNames(array($revision_name))\n  ->executeOne();\nif (!($result instanceof DifferentialRevision)) {\n  // fix the name before invoking attach-commit\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  // 'Revision ... does not exist' -> re-check monogram/policy, do not retry blindly.\n}","preventionTips":["Always use D<id> monograms for revisions in CLI invocations","Keep a single source of truth for revision IDs; never strip or swap the D prefix","Remember policies apply: a revision invisible to the viewer behaves as nonexistent"],"tags":["phabricator","differential","cli","attach-commit","revision","not-found","object-query"],"backgroundTag":"entity-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}