{"record":{"id":"38cca5e82211f6a2","repo":"phacility/phabricator","slug":"err-bad-document","errorCode":"ERR-BAD-DOCUMENT","errorMessage":"No such document exists.","messagePattern":"No such document exists\\.","errorType":"error_code","errorClass":"ConduitException","httpStatus":null,"severity":"error","filePath":"src/applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php","lineNumber":50,"sourceCode":"\n  protected function defineErrorTypes() {\n    return array(\n      'ERR-BAD-DOCUMENT' => pht('No such document exists.'),\n    );\n  }\n\n  protected function execute(ConduitAPIRequest $request) {\n    $slug = $request->getValue('slug');\n    if ($slug === null || !strlen($slug)) {\n      throw new Exception(pht('Field \"slug\" must be non-empty.'));\n    }\n\n    $doc = id(new PhrictionDocumentQuery())\n      ->setViewer($request->getUser())\n      ->withSlugs(array(PhabricatorSlug::normalize($slug)))\n      ->executeOne();\n    if (!$doc) {\n      throw new ConduitException('ERR-BAD-DOCUMENT');\n    }\n\n    $content = id(new PhrictionContent())->loadAllWhere(\n      'documentID = %d ORDER BY version DESC',\n      $doc->getID());\n\n    $results = array();\n    foreach ($content as $version) {\n      $results[] = $this->buildDocumentContentDictionary(\n        $doc,\n        $version);\n    }\n\n    return $results;\n  }\n\n}\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php#L32-L68","documentation":"phriction.history looks up the document by normalized slug; on miss it raises a ConduitException with error code ERR-BAD-DOCUMENT, which the method declares in defineErrorTypes(). Well-behaved Conduit clients therefore get a structured, catchable error code instead of having to string-match.","triggerScenarios":"Calling phriction.history with a slug that does not exist or that the acting user cannot see, so the policy-filtered PhrictionDocumentQuery returns no result.","commonSituations":"Slug typos or renamed pages; bots whose view policy excludes them from the document; querying documents that were deleted.","solutions":["Verify the slug with phriction.info (same code path) or in the web UI","Check the acting user's view access to the document","Catch ERR-BAD-DOCUMENT client-side and degrade gracefully (skip, log, or prompt)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  $result = $client->callMethodSynchronous('phriction.history', $params);\n} catch (ConduitClientException $ex) {\n  if ($ex->getErrorCode() === 'ERR-BAD-DOCUMENT') {\n    // slug unknown to this viewer: skip, log, or prompt for the correct path\n  }\n}","preventionTips":["Branch on the structured ERR-BAD-DOCUMENT code, never on message text","Verify slugs with phriction.info during development","Ensure the acting user has view access to the documents being queried"],"tags":["phabricator","phriction","conduit","not-found","err-bad-document"],"backgroundTag":"entity-not-found-by-slug","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}