phacility/phabricator · error · Exception
Value for "number" argument must be an integer or double, go
Error message
Value for "number" argument must be an integer or double, got %s.
What it means
For 'number' typed chart function arguments, PhabricatorChartFunctionArgument::newValue() accepts only PHP int or float. Anything else — numeric strings, null, booleans — throws this Exception with the actual type from phutil_describe_type().
Source
Thrown at src/applications/fact/chart/PhabricatorChartFunctionArgument.php:131
'beginning with a function name as a string. The first list '.
'item has the wrong type, %s.',
phutil_describe_type($function_name)));
}
$functions = PhabricatorChartFunction::getAllFunctions();
if (!isset($functions[$function_name])) {
throw new Exception(
pht(
'Function "%s" is unknown. Valid functions are: %s',
$function_name,
implode(', ', array_keys($functions))));
}
return id(clone $functions[$function_name])
->setArguments($value);
case 'number':
if (!is_float($value) && !is_int($value)) {
throw new Exception(
pht(
'Value for "number" argument must be an integer or double, '.
'got %s.',
phutil_describe_type($value)));
}
return $value;
}
throw new PhutilMethodNotImplementedException();
}
}
View on GitHub (pinned to 5720a38cfe)
Solutions
- Cast to int/float before use: (int)$value or (float)$value when the source is a string parameter.
- Validate with is_int($v) || is_float($v) during spec construction.
- Reject null/boolean early at the request boundary.
- Note there is no string coercion: strict typing is intentional.
Example fix
// before
$arguments[] = $request->getValue('limit'); // '100' (string) -> Exception
// after
$limit = $request->getValue('limit');
$arguments[] = (int)$limit; Defensive patterns
Strategy: type-guard
Type guard
function is_chart_number($value) {
return is_int($value) || is_float($value);
} Prevention
- Cast string request parameters with (int)/(float) before use.
- Note there is no coercion of numeric strings — strict int/float only.
- Reject null and bool early when parsing external input.
When it happens
Trigger: Passing '7' (string) instead of 7, null from a missing key, or true/false as a number argument, e.g. array('constant', '100') from unvalidated request or JSON input.
Common situations: HTTP/Conduit request values arriving as strings and used unvalidated; JSON decoding configured to produce strings; idx() defaults of null flowing into argument lists; form inputs never cast.
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
- Value for "fact-key" argument must be a string, got %s.
- Value for "function" argument must be a natural list beginni
- Value for "function" argument must be a function definition,
- Value for "function" argument must be a natural list, not a
- Value for "function" argument must be a list with a function
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/aad197b566711b4c.
Report an issue: GitHub.