phacility/phabricator · error · Exception
Value for "function" argument must be a function definition,
Error message
Value for "function" argument must be a function definition, formatted as a list, like: [fn, arg1, arg, ...]. Actual value is %s.
What it means
For 'function' typed chart arguments, PhabricatorChartFunctionArgument::newValue() accepts either an existing PhabricatorChartFunction object or a list definition [fn, arg1, arg2, ...]. Any non-array value (string, number, null) throws this Exception, reporting the actual PHP type.
Source
Thrown at src/applications/fact/chart/PhabricatorChartFunctionArgument.php:84
$facts = PhabricatorFact::getAllFacts();
$fact = idx($facts, $value);
if (!$fact) {
throw new Exception(
pht(
'Fact key "%s" is not a known fact key.',
$value));
}
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(View on GitHub (pinned to 5720a38cfe)
Solutions
- Wrap nested functions as lists: use array('sum', 1, 2) or ['sum', 1, 2], not 'sum'.
- Pass an existing PhabricatorChartFunction object if you already built one.
- Validate structure before constructing: the value must be is_array().
- Check for nulls introduced by optional request parameters feeding the argument list.
Example fix
// before
$arguments[] = 'constant'; // string where function definition expected -> Exception
// after
$arguments[] = array('constant', 100); // [fn, arg1, ...] list form Defensive patterns
Strategy: type-guard
Type guard
function is_function_definition($value) {
return $value instanceof PhabricatorChartFunction || is_array($value);
} Prevention
- Remember nested functions use the [fn, arg1, ...] list form, not a bare name.
- Pass an already-built PhabricatorChartFunction object when in doubt.
- Validate external spec shapes before handing them to chart APIs.
When it happens
Trigger: Supplying a bare string function name ('sum') or scalar where a nested function definition list is required, e.g. arguments like array('sum', 1) nested inside another function's argument list where the inner value is not an array.
Common situations: Assuming the argument takes a function name string instead of a list; passing a null from an unset variable; JSON specs that inline scalars where nested functions are expected.
Related errors
- Value for "function" argument must be a natural list, not a
- 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/63a59a7882dd4061.
Report an issue: GitHub.