{"record":{"id":"57c6c1a0f1a31b78","repo":"phacility/phabricator","slug":"err-bad-revision-57c6c1","errorCode":"ERR_BAD_REVISION","errorMessage":"ERR_BAD_REVISION","messagePattern":"ERR_BAD_REVISION","errorType":"error_code","errorClass":"ConduitException","httpStatus":null,"severity":"error","filePath":"src/applications/differential/conduit/DifferentialUpdateRevisionConduitAPIMethod.php","lineNumber":69,"sourceCode":"      ->withIDs(array($request->getValue('diffid')))\n      ->executeOne();\n    if (!$diff) {\n      throw new ConduitException('ERR_BAD_DIFF');\n    }\n\n    $revision = id(new DifferentialRevisionQuery())\n      ->setViewer($request->getUser())\n      ->withIDs(array($request->getValue('id')))\n      ->needReviewers(true)\n      ->needActiveDiffs(true)\n      ->requireCapabilities(\n        array(\n          PhabricatorPolicyCapability::CAN_VIEW,\n          PhabricatorPolicyCapability::CAN_EDIT,\n        ))\n      ->executeOne();\n    if (!$revision) {\n      throw new ConduitException('ERR_BAD_REVISION');\n    }\n\n    if ($revision->isPublished()) {\n      throw new ConduitException('ERR_CLOSED');\n    }\n\n    $this->applyFieldEdit(\n      $request,\n      $revision,\n      $diff,\n      $request->getValue('fields', array()),\n      $request->getValue('message'));\n\n    return array(\n      'revisionid'  => $revision->getID(),\n      'uri'         => PhabricatorEnv::getURI('/D'.$revision->getID()),\n    );\n  }","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialUpdateRevisionConduitAPIMethod.php#L51-L87","documentation":"The revision referenced by id must exist and the acting user must hold both CAN_VIEW and CAN_EDIT on it (the query calls requireCapabilities). Nonexistent, invisible, and non-editable revisions all surface as ERR_BAD_REVISION, so this single code covers both not-found and permission failure.","triggerScenarios":"id is wrong or nonexistent; the user is not the author and has no edit rights; the view policy hides the revision so the policy-filtered query returns null; the ID is prefixed with 'D'.","commonSituations":"Bots or teammates trying to update someone else's revision; a revision moved under a restrictive project policy; ID mix-ups across instances; automation running with the wrong token.","solutions":["Confirm the numeric revision id (no 'D' prefix).","Ensure the conduit user is the revision author or otherwise has edit rights.","Pre-check visibility with differential.revision.search as the same user; an invisible revision fails the same way.","Check you are on the instance that owns the revision."],"exampleFix":"// before: update runs as a bot that cannot edit the revision\n$client->callMethodSynchronous('differential.updaterevision', array(\n  'id' => 123,\n  'diffid' => 456,\n));\n\n// after: run as the revision author's token, numeric ids only\n$client->callMethodSynchronous('differential.updaterevision', array(\n  'id' => 123,\n  'diffid' => 456,\n));","handlingStrategy":"validation","validationCode":"$result = $client->callMethodSynchronous('differential.revision.search', array(\n  'constraints' => array('ids' => array($revision_id)),\n));\nif (empty($result['data'])) {\n  throw new RuntimeException(\n    'Revision missing or not visible to this user.');\n}","typeGuard":"function isRevisionID($value) {\n  return is_int($value) && $value > 0;\n}","tryCatchPattern":"try {\n  $result = $client->callMethodSynchronous(\n    'differential.updaterevision', $params);\n} catch (ConduitClientException $ex) {\n  if ($ex->getErrorCode() === 'ERR_BAD_REVISION') {\n    // not found or no edit rights: re-check id, author, and policies\n  } else {\n    throw $ex;\n  }\n}","preventionTips":["Update revisions only as their author or a user with edit rights.","Pre-check visibility with differential.revision.search under the same token.","Send numeric ids only, without the 'D' prefix."],"tags":["phabricator","conduit","differential","revision-not-found","permissions"],"backgroundTag":"resource-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}