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

  1. Supply at least as many arguments as the function declares; check the message for the expected minimum count.
  2. When filtering argument lists dynamically, use a predicate that keeps 0/false (avoid bare array_filter).
  3. Re-save stored charts after upgrading if function signatures gained required arguments.
  4. 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

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


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