phacility/phabricator · error · ConduitException

ERR-BAD-DOCUMENT

ERR-BAD-DOCUMENT

Error message

No such document exists.

What it means

phriction.info loads the document (with content) by normalized slug; on miss it raises a ConduitException with error code ERR-BAD-DOCUMENT, declared in defineErrorTypes(). Clients can branch on the structured code instead of parsing the message text.

Source

Thrown at src/applications/phriction/conduit/PhrictionInfoConduitAPIMethod.php:51

  protected function defineErrorTypes() {
    return array(
      'ERR-BAD-DOCUMENT' => pht('No such document exists.'),
    );
  }

  protected function execute(ConduitAPIRequest $request) {
    $slug = $request->getValue('slug');
    if ($slug === null || !strlen($slug)) {
      throw new Exception(pht('Field "slug" must be non-empty.'));
    }

    $document = id(new PhrictionDocumentQuery())
      ->setViewer($request->getUser())
      ->withSlugs(array(PhabricatorSlug::normalize($slug)))
      ->needContent(true)
      ->executeOne();
    if (!$document) {
      throw new ConduitException('ERR-BAD-DOCUMENT');
    }

    return $this->buildDocumentInfoDictionary($document);
  }

}

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Confirm the slug in the web UI as the same user
  2. Grant view access if the document should be visible to the caller
  3. Handle ERR-BAD-DOCUMENT in the client as the not-found branch
Defensive patterns

Strategy: try-catch

Try / catch

try {
  $info = $client->callMethodSynchronous('phriction.info', array('slug' => $slug));
} catch (ConduitClientException $ex) {
  if ($ex->getErrorCode() === 'ERR-BAD-DOCUMENT') {
    $info = null; // not found (or hidden): create-if-missing flows go here
  }
}

Prevention

When it happens

Trigger: Calling conduit method phriction.info with a slug that does not exist or that the acting user has no view access to, so the policy-filtered query returns nothing.

Common situations: Checking whether a page exists before create/edit; renamed or deleted documents; restricted documents probed by automation users.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/87b262556c33eda6. Report an issue: GitHub.