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
- Use the positional list form: array('sum', 1, 2).
- Do not use the 'function'/'arguments' dictionary shape for nested function arguments.
- Call array_values($value) to re-index a sparse array into a natural list.
- 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
- Never use the 'function'/'arguments' dictionary shape for nested function arguments.
- In JSON specs, nested function definitions must be arrays, not objects.
- Normalize sparse arrays with array_values() before use.
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
- Value for "function" argument must be a function definition,
- Value for "fact-key" argument must be a string, got %s.
- Value for "function" argument must be a list with a function
- Value for "function" argument must be a natural list beginni
- Value for "number" argument must be an integer or double, go
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/2c41521f17f02b38.
Report an issue: GitHub.