phacility/phabricator · error · Exception

Field "slug" must be non-empty.

Error message

Field "slug" must be non-empty.

What it means

The phriction.edit Conduit method identifies the target document solely by the slug field; execute() rejects a null or zero-length slug before the document query runs. It is a plain Exception, so Conduit clients receive a generic error rather than a structured code.

Source

Thrown at src/applications/phriction/conduit/PhrictionEditConduitAPIMethod.php:29

  }

  protected function defineParamTypes() {
    return array(
      'slug'          => 'required string',
      'title'         => 'optional string',
      'content'       => 'optional string',
      'description'   => 'optional string',
    );
  }

  protected function defineReturnType() {
    return 'nonempty dict';
  }

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

    $doc = id(new PhrictionDocumentQuery())
      ->setViewer($request->getUser())
      ->withSlugs(array(PhabricatorSlug::normalize($slug)))
      ->needContent(true)
      ->requireCapabilities(
        array(
          PhabricatorPolicyCapability::CAN_VIEW,
          PhabricatorPolicyCapability::CAN_EDIT,
        ))
      ->executeOne();
    if (!$doc) {
      throw new Exception(pht('No such document.'));
    }

    $xactions = array();
    if ($request->getValue('title')) {

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Pass the non-empty document slug in the call parameters
  2. Validate the parameter map before invoking phriction.edit when the caller cannot guarantee it
  3. Use phriction.info with the same slug first to confirm the document resolves

Example fix

// before
$params = array('content' => $new_content);
$client->callMethodSynchronous('phriction.edit', $params);

// after
$params = array(
  'slug' => '/runbook/deploy',
  'content' => $new_content,
);
$client->callMethodSynchronous('phriction.edit', $params);
Defensive patterns

Strategy: validation

Validate before calling

$slug = (string)idx($params, 'slug', '');
if ($slug === '') {
  throw new InvalidArgumentException('phriction.edit: slug must be non-empty');
}
$result = $client->callMethodSynchronous('phriction.edit', $params);

Try / catch

try {
  $result = $client->callMethodSynchronous('phriction.edit', $params);
} catch (Exception $ex) {
  if (strpos($ex->getMessage(), 'must be non-empty') !== false) {
    // fix the caller: the edit target was never specified
  }
}

Prevention

When it happens

Trigger: Calling conduit method phriction.edit with slug omitted, null, or the empty string, so the lookup key for the document to edit is missing.

Common situations: Edit automation where the slug comes from an upstream field that is sometimes blank; parameter typos like 'path' instead of 'slug'; template code copy-pasted with the slug line removed.

Related errors


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