phacility/phabricator · error · Exception

Field "name" must be non-empty.

Error message

Field "name" must be non-empty.

What it means

name is the property key written to the diff property row (conventional examples are 'arc:lint', 'arc:unit', 'unit:result'). Null or zero-length names are rejected because a stored property needs a key.

Source

Thrown at src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php:45

    return array(
      'ERR_NOT_FOUND' => pht('Diff was not found.'),
    );
  }

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

    $diff_id = $request->getValue('diff_id');
    if ($diff_id === null) {
      throw new Exception(pht('Field "diff_id" must be non-null.'));
    }

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

    $data = json_decode($data, true);

    self::updateDiffProperty($diff_id, $name, $data);
  }

  private static function updateDiffProperty($diff_id, $name, $data) {
    $property = id(new DifferentialDiffProperty())->loadOneWhere(
      'diffID = %d AND name = %s',
      $diff_id,
      $name);
    if (!$property) {
      $property = new DifferentialDiffProperty();
      $property->setDiffID($diff_id);
      $property->setName($name);
    }
    $property->setData($data);

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Pass a non-empty, stable property name such as 'arc:lint' or 'unit:result'.
  2. Check strlen($name) before the call.
  3. Derive names from a whitelist of the property keys your tooling reads.

Example fix

// before
$params['name'] = $prop_name; // $prop_name may be null

// after
if (!is_string($prop_name) || strlen($prop_name) === 0) {
  throw new InvalidArgumentException('Property name must be non-empty.');
}
$params['name'] = $prop_name;
Defensive patterns

Strategy: validation

Validate before calling

if (!is_string($name) || strlen($name) === 0) {
  throw new InvalidArgumentException(
    'Property name must be a non-empty string.');
}
$params['name'] = $name;

Type guard

function isPropertyName($value) {
  return is_string($value) && strlen($value) > 0;
}

Try / catch

try {
  $client->callMethodSynchronous('differential.setdiffproperty', $params);
} catch (ConduitClientException $ex) {
  if (strpos($ex->getMessage(), '"name" must be non-empty') !== false) {
    // caller bug: pass a real key such as 'arc:lint'
  } else {
    throw $ex;
  }
}

Prevention

When it happens

Trigger: Passing name as null or '' — the key came from a variable that was never set, arguments were transposed, or the name was built by concatenation that produced an empty string.

Common situations: Copy-pasted call sites with a renamed constant; clients that send the value in name and the key in data; whitespace-trimmed names that reduced to empty.

Related errors


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