phacility/phabricator · error · Exception

Value for "function" argument must be a natural list, not a

Error message

Value for "function" argument must be a natural list, not a dictionary. Actual value is "%s".

What it means

A 'function' argument that is an array must be a natural list (zero-based sequential integer keys). PhabricatorChartFunctionArgument::newValue() rejects dictionaries or sparse arrays via phutil_is_natural_list(), reporting the actual type shape in the message.

Source

Thrown at src/applications/fact/chart/PhabricatorChartFunctionArgument.php:93

        return $fact;
      case 'function':
        // If this is already a function object, just return it.
        if ($value instanceof PhabricatorChartFunction) {
          return $value;
        }

        if (!is_array($value)) {
          throw new Exception(
            pht(
              'Value for "function" argument must be a function definition, '.
              'formatted as a list, like: [fn, arg1, arg, ...]. Actual value '.
              'is %s.',
              phutil_describe_type($value)));
        }

        if (!phutil_is_natural_list($value)) {
          throw new Exception(
            pht(
              'Value for "function" argument must be a natural list, not '.
              'a dictionary. Actual value is "%s".',
              phutil_describe_type($value)));
        }

        if (!$value) {
          throw new Exception(
            pht(
              'Value for "function" argument must be a list with a function '.
              'name; got an empty list.'));
        }

        $function_name = array_shift($value);

        if (!is_string($function_name)) {
          throw new Exception(
            pht(

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Use the positional list form: array('sum', 1, 2).
  2. Do not use the 'function'/'arguments' dictionary shape for nested function arguments.
  3. Call array_values($value) to re-index a sparse array into a natural list.
  4. In JSON payloads, ensure nested function definitions are arrays, not objects.

Example fix

// before
$arguments[] = array(
  'function' => 'sum',
  'arguments' => array(1, 2),
); // dictionary, not natural list -> Exception

// after
$arguments[] = array('sum', 1, 2); // natural list [fn, arg1, arg2]
Defensive patterns

Strategy: type-guard

Type guard

function is_natural_function_list($value) {
  return is_array($value) && phutil_is_natural_list($value);
}

Prevention

When it happens

Trigger: Passing an array with string keys (e.g. array('function' => 'sum', 'arguments' => array(1))) or a non-sequential key set where the [fn, arg1, ...] positional list form is required.

Common situations: Confusing the dictionary form used by newFromDictionary() with the list form used inside argument lists; hand-built PHP arrays with named keys; JSON objects where a JSON array was required.

Related errors


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