phacility/phabricator · error · Exception

Function "%s" expects at least %s argument(s), but only %s a

Error message

Function "%s" expects at least %s argument(s), but only %s argument(s) were provided.

What it means

While consuming arguments in parseArguments(), PhabricatorChartFunctionArgumentParser shifts raw arguments as each declared argument is parsed. If declared arguments remain but the raw argument supply ($this->unconsumedArguments) is exhausted, this Exception reports the signature and the wanted vs provided counts.

Source

Thrown at src/applications/fact/chart/PhabricatorChartFunctionArgumentParser.php:142

              $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));
      }
    }

    while ($this->unparsedArguments) {
      $argument = array_shift($this->unparsedArguments);
      $name = $argument->getName();

      if (!$this->unconsumedArguments) {
        throw new Exception(
          pht(
            'Function "%s" expects at least %s argument(s), but only %s '.
            'argument(s) were provided.',
            $this->getFunctionArgumentSignature(),
            $want_count,
            $have_count));
      }

      $raw_argument = array_shift($this->unconsumedArguments);
      $this->argumentPosition++;

      $is_repeatable = $argument->getRepeatable();

      // If this argument is repeatable and we have more arguments, add it
      // back to the end of the list so we can continue parsing.
      if ($is_repeatable && $this->unconsumedArguments) {
        $this->unparsedArguments[] = $argument;
      }

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Add the missing arguments so the count meets the declared signature (see counts in the message).
  2. Audit code that builds the raw argument list for accidental drops (filter, slice, unset).
  3. Log the raw argument list when constructing functions from external input to catch undersized payloads.
  4. Re-save charts created before the function gained arguments.

Example fix

// before
$fn = array('sum'); // too few raw arguments for signature -> Exception in parse loop

// after
$fn = array('sum', 1, 2);
Defensive patterns

Strategy: validation

Validate before calling

if (count($raw_arguments) < count($function->newArguments())) {
  // pad or reject before parseArguments() runs
  throw new Exception('Argument list too short for function');
}

Prevention

When it happens

Trigger: Same essential condition as the other count checks — fewer raw arguments than the function declares — surfaced from the per-argument loop rather than the up-front count check (e.g. paths where haveAllArguments is not set, or after repeatable-argument consumption).

Common situations: Undersupplied argument lists from dynamic construction; array_filter or array_slice trimming values; hand-written dictionaries missing trailing arguments.

Related errors


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