phacility/phabricator · error · Exception
Function "%s" expects %s or more argument(s), but only %s ar
Error message
Function "%s" expects %s or more argument(s), but only %s argument(s) were provided.
What it means
PhabricatorChartFunctionArgumentParser::parseArguments() compares the number of raw arguments against declared arguments. When the function declares a repeatable argument (so all declared args are required minimums) and fewer raw arguments were supplied, this Exception reports the function signature, wanted count, and provided count.
Source
Thrown at src/applications/fact/chart/PhabricatorChartFunctionArgumentParser.php:118
return $this;
}
public function getAllArguments() {
return array_values($this->argumentMap);
}
public function getRawArguments() {
return $this->rawArguments;
}
public function parseArguments() {
$have_count = count($this->rawArguments);
$want_count = count($this->argumentMap);
if ($this->haveAllArguments) {
if ($this->repeatableArgument) {
if ($want_count > $have_count) {
throw new Exception(
pht(
'Function "%s" expects %s or more argument(s), but only %s '.
'argument(s) were provided.',
$this->getFunctionArgumentSignature(),
$want_count,
$have_count));
}
} else if ($want_count !== $have_count) {
throw new Exception(
pht(
'Function "%s" expects %s argument(s), but %s argument(s) were '.
'provided.',
$this->getFunctionArgumentSignature(),
$want_count,
$have_count));
}
}
View on GitHub (pinned to 5720a38cfe)
Solutions
- Supply at least as many arguments as the function declares; check the message for the expected minimum count.
- When filtering argument lists dynamically, use a predicate that keeps 0/false (avoid bare array_filter).
- Re-save stored charts after upgrading if function signatures gained required arguments.
- Inspect the function's newArguments() to see the declared minimum.
Example fix
// before
$arguments = array_filter($values); // drops 0 values -> too few args -> Exception
// after
$arguments = array_filter($values, function ($v) { return $v !== null; }); Defensive patterns
Strategy: validation
Validate before calling
$declared = count($function->newArguments()); // or your known minimum
if (count($raw_arguments) < $declared) {
throw new Exception('Too few arguments for chart function');
} Prevention
- Know each function's declared minimum argument count before building specs.
- Avoid bare array_filter on argument lists — it drops falsy values like 0.
- Count-check argument lists when they come from user input.
When it happens
Trigger: Calling parseArguments() (or building a chart function from a dictionary) with fewer arguments than the function's declared arguments, when at least one argument is repeatable — e.g. a function declared as (min, max...) invoked with zero arguments.
Common situations: Omitting optional-looking trailing arguments in hand-written specs; dynamic argument lists that dropped elements (e.g. array_filter removing falsy values like 0); stored charts saved before an argument was added to a function signature.
Related errors
- Function "%s" expects %s argument(s), but %s argument(s) wer
- Function "%s" expects at least %s argument(s), but only %s a
- Argument "%s" (in position "%s") to function "%s" is invalid
- Trying to construct a dataset of type "%s", but this type is
- Attempting to build function "%s" from dictionary, but that
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/60949a2ad2d8ffd3.
Report an issue: GitHub.