{"record":{"id":"4683d59b065815ce","repo":"phacility/phabricator","slug":"commit-s-does-not-exist","errorCode":null,"errorMessage":"Commit \"%s\" does not exist.","messagePattern":"Commit \"(.+?)\" does not exist\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/differential/management/PhabricatorDifferentialAttachCommitWorkflow.php","lineNumber":38,"sourceCode":"\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $argv = $args->getArg('argv');\n    if (count($argv) !== 2) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify a commit and a revision to attach it to.'));\n    }\n\n    $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","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/management/PhabricatorDifferentialAttachCommitWorkflow.php#L20-L56","documentation":"In attach-commit, the commit positional argument is resolved through DiffusionCommitQuery->withIdentifiers()->executeOne(); when no visible commit matches, the workflow throws this usage exception. It means the identifier did not resolve to any imported commit under the viewer's policies, not merely that the string is malformed.","triggerScenarios":"Passing an ambiguous short hash without repository context (DiffusionCommitQuery needs enough of the hash or repository scoping to resolve it); the commit exists in the repository but has not been discovered/imported yet; the viewer cannot see the repository; typo in the hash; using a branch name instead of a commit identifier.","commonSituations":"Fresh clones where './bin/repository discover' has not run; repositories stuck in an importing state (check ./bin/repository importing); running the workflow as a user restricted by repository view policies; copy-pasting truncated hashes from a terminal.","solutions":["Use the fully qualified identifier (full 40-char Git SHA or hg full hash) or the r<REPO><short-hash> monogram so the query resolves unambiguously","Confirm the commit is imported: run './bin/repository discover --repoid <id>' then './bin/repository importing' and let daemons finish parsing","Run the command as an administrator or a viewer who can see the repository","Verify the hash exists in the upstream repo (git rev-parse <hash>) before retrying"],"exampleFix":"# before\nphabricator/ $ ./bin/differential attach-commit abc12 D456\nUsage Exception: Commit \"abc12\" does not exist.\n\n# after\nphabricator/ $ ./bin/differential attach-commit rP703dcf56d0b6a4e01a52b1c6a1a1a8d1f8e2ab3c D456","handlingStrategy":"validation","validationCode":"// Verify the commit resolves for this viewer before attaching:\nphabricator/ $ ./bin/repository importing   # confirm nothing pending\nphabricator/ $ ./bin/differential attach-commit rP703dcf56... D456  # full identifier","typeGuard":"// Use unambiguous identifiers only: full VCS hash or r<REPO><hash> monogram\npreg_match('/^r[A-Z]+[0-9a-f]{7,40}$|^[0-9a-f]{40}$/', $commit_name)","tryCatchPattern":"try {\n  $workflow->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // Missing commit: check discovery/import state, then retry with a full hash.\n}","preventionTips":["Prefer full 40-char hashes or r<REPO> monograms over short ambiguous hashes","Run './bin/repository discover' and wait for import queues before attaching freshly pushed commits","Run as a user who can see the target repository"],"tags":["phabricator","differential","cli","attach-commit","commit","not-found","diffusion"],"backgroundTag":"entity-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}