phacility/phabricator · error · Exception

Field "%s" expects a list of strings, but received a value o

Error message

Field "%s" expects a list of strings, but received a value of type "%s".

What it means

DifferentialCommitMessageField::readStringListFieldValueFromConduit() validates that list-type commit-message fields receive a PHP array; any non-array value (including null, which the single-string variant tolerates) throws with the field key and received type. It guards fields whose value is a list of strings (e.g., reviewers-style custom fields) on Conduit write paths such as 'differential.revision.edit'.

Source

Thrown at src/applications/differential/field/DifferentialCommitMessageField.php:171

    if ($value === null) {
      return $value;
    }

    if (!is_string($value)) {
      throw new Exception(
        pht(
          'Field "%s" expects a string value, but received a value of type '.
          '"%s".',
          $this->getCommitMessageFieldKey(),
          gettype($value)));
    }

    return $value;
  }

  protected function readStringListFieldValueFromConduit($value) {
    if (!is_array($value)) {
      throw new Exception(
        pht(
          'Field "%s" expects a list of strings, but received a value of type '.
          '"%s".',
          $this->getCommitMessageFieldKey(),
          gettype($value)));
    }

    return $value;
  }

  protected function isCustomFieldEnabled($key) {
    $field_list = PhabricatorCustomField::getObjectFields(
      new DifferentialRevision(),
      DifferentialCustomField::ROLE_DEFAULT);

    $fields = $field_list->getFields();
    return isset($fields[$key]);
  }

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Send a JSON array of strings for the field key named in the message, even for a single value (["alice"] not "alice")
  2. Never send null for a list field; send an empty array [] to clear it
  3. Add a client-side check that the value is an array before issuing the Conduit call
  4. If the field should accept scalars, override readFieldValueFromConduit() in the field subclass to wrap scalars into a one-element array

Example fix

// before
conduit.call('differential.revision.edit', {
  transactions: [{type: 'revision.setfield',
    value: {field: 'custom:reviewers-ext', value: 'alice'}}]
});

// after
conduit.call('differential.revision.edit', {
  transactions: [{type: 'revision.setfield',
    value: {field: 'custom:reviewers-ext', value: ['alice']}}]
});
Defensive patterns

Strategy: type-guard

Validate before calling

// PHP client: force list-of-strings shape before the Conduit call
foreach ($list_fields as $k) {
  $v = $fields[$k];
  if ($v === null) {
    $fields[$k] = array();          // null is rejected; use [] to clear
  } elseif (is_string($v)) {
    $fields[$k] = array($v);        // wrap single values
  } elseif (is_array($v)) {
    $fields[$k] = array_map('strval', $v);
  }
}

Type guard

function isValidStringListFieldValue($value) {
  return is_array($value)
    && array_reduce($value, function ($ok, $v) { return $ok && is_string($v); }, true);
}

Try / catch

try {
  $field->readFieldValueFromConduit($value);
} catch (Exception $ex) {
  // Wrap scalars / replace null with [] for the named field, then retry.
}

Prevention

When it happens

Trigger: Passing a single string where the field expects a list (e.g., 'alice' instead of array('alice')); passing null for a list field (null is rejected here, unlike the string variant); passing an int or object from a loosely typed client payload.

Common situations: Clients upgrading from single-value to list-value custom fields and still sending scalars; JSON payloads where the list key is omitted or replaced by a scalar; automation sharing field templates between string and list fields.

Understand the failure class

Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.

Related errors


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