{"record":{"id":"034dc4e01e46e546","repo":"phacility/phabricator","slug":"this-revision-has-no-diffs-something-has-gone-qui","errorCode":null,"errorMessage":"This revision has no diffs. Something has gone quite wrong.","messagePattern":"This revision has no diffs\\. Something has gone quite wrong\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/applications/differential/controller/DifferentialRevisionViewController.php","lineNumber":67,"sourceCode":"    $revision = id(new DifferentialRevisionQuery())\n      ->withIDs(array($this->revisionID))\n      ->setViewer($viewer)\n      ->needReviewers(true)\n      ->needReviewerAuthority(true)\n      ->needCommitPHIDs(true)\n      ->executeOne();\n    if (!$revision) {\n      return new Aphront404Response();\n    }\n\n    $diffs = id(new DifferentialDiffQuery())\n      ->setViewer($viewer)\n      ->withRevisionIDs(array($this->revisionID))\n      ->execute();\n    $diffs = array_reverse($diffs, $preserve_keys = true);\n\n    if (!$diffs) {\n      throw new Exception(\n        pht('This revision has no diffs. Something has gone quite wrong.'));\n    }\n\n    $revision->attachActiveDiff(last($diffs));\n\n    $diff_vs = $this->getOldDiffID($revision, $diffs);\n    if ($diff_vs instanceof AphrontResponse) {\n      return $diff_vs;\n    }\n\n    $target_id = $this->getNewDiffID($revision, $diffs);\n    if ($target_id instanceof AphrontResponse) {\n      return $target_id;\n    }\n\n    $target = $diffs[$target_id];\n\n    $target_manual = $target;","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/controller/DifferentialRevisionViewController.php#L49-L85","documentation":"A revision page requires at least one diff; the controller throws this invariant error when a DifferentialRevision row exists with zero attached diffs. Normal Phabricator flows always create revisions together with a first diff, so this error signals damaged or abnormal data.","triggerScenarios":"Opening a revision whose diffs were all deleted or never created: revisions inserted directly into the database, partial creation failures, or cleanup scripts that removed diffs without the revision.","commonSituations":"Rows created by migration or seeding scripts that bypass the API; broken imports; database-level deletion of diffs that left empty revisions behind.","solutions":["Create revisions through the API or UI (differential.creatediff plus differential.updaterevision) so every revision gets at least one diff.","Repair the data: attach a diff to the revision or remove the empty revision row.","Restore from backups if the diffs were lost accidentally."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // render or operate on the revision\n} catch (Exception $ex) {\n  if (preg_match('/has no diffs/', $ex->getMessage())) {\n    // data integrity violation: quarantine the revision and alert the admin\n  } else {\n    throw $ex;\n  }\n}","preventionTips":["Create revisions through the API or UI so they always receive a first diff.","Never insert revision rows directly into the database.","When removing diffs, remove their revisions in the same operation; back up first."],"tags":["phabricator","differential","revision","data-integrity"],"backgroundTag":"data-integrity-violation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}