{"record":{"id":"01a4b270c1710777","repo":"phacility/phabricator","slug":"err-bad-diff-01a4b2","errorCode":"ERR_BAD_DIFF","errorMessage":"ERR_BAD_DIFF","messagePattern":"ERR_BAD_DIFF","errorType":"error_code","errorClass":"ConduitException","httpStatus":null,"severity":"error","filePath":"src/applications/differential/conduit/DifferentialUpdateRevisionConduitAPIMethod.php","lineNumber":54,"sourceCode":"\n  protected function defineErrorTypes() {\n    return array(\n      'ERR_BAD_DIFF'     => pht('Bad diff ID.'),\n      'ERR_BAD_REVISION' => pht('Bad revision ID.'),\n      'ERR_WRONG_USER'   => pht('You are not the author of this revision.'),\n      'ERR_CLOSED'       => pht('This revision has already been closed.'),\n    );\n  }\n\n  protected function execute(ConduitAPIRequest $request) {\n    $viewer = $request->getUser();\n\n    $diff = id(new DifferentialDiffQuery())\n      ->setViewer($viewer)\n      ->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()) {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialUpdateRevisionConduitAPIMethod.php#L36-L72","documentation":"differential.updaterevision first loads the diff identified by the diffid parameter. If no visible diff with that ID exists — nonexistent, deleted, or hidden by policy from the viewer — the method throws ERR_BAD_DIFF before it touches the revision.","triggerScenarios":"diffid is null or unset, refers to a diff on another instance, points at a deleted diff, or the acting user cannot see the diff because of policies.","commonSituations":"Multi-step arc-style flows where creatediff and updaterevision run under different users or tokens; retrying an update after the diff was removed; IDs copy-pasted between instances.","solutions":["Send the numeric diffid exactly as returned by differential.creatediff in the same session and under the same user.","Verify the diff exists (differential.diff.search, or load the revision's diffs) before updating.","Ensure the user who created the diff is the user who performs the update."],"exampleFix":"// before\n$client->callMethodSynchronous('differential.updaterevision', array(\n  'id' => $revision_id,\n  'diffid' => $diff_id, // $diff_id may be null or from another instance\n));\n\n// after\nif ($diff_id === null || $diff_id <= 0) {\n  throw new InvalidArgumentException('diffid must be a positive integer diff ID.');\n}\n$client->callMethodSynchronous('differential.updaterevision', array(\n  'id' => $revision_id,\n  'diffid' => $diff_id,\n));","handlingStrategy":"validation","validationCode":"if ($diff_id === null || $diff_id <= 0) {\n  throw new InvalidArgumentException(\n    'diffid must be a positive integer diff ID.');\n}\n// prefer: $diff_id taken directly from the creatediff response in this run","typeGuard":"function isDiffID($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_DIFF') {\n    // diff missing or invisible: recreate the diff, then retry\n  } else {\n    throw $ex;\n  }\n}","preventionTips":["Create the diff and update the revision with the same user/token in one flow.","Do not cache diff ids across instances or sessions.","Treat ERR_BAD_DIFF as permanent for that diff id; recreate the diff instead of retrying."],"tags":["phabricator","conduit","differential","diff-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}