{"record":{"id":"28fc9cd1c9f09bb2","repo":"phacility/phabricator","slug":"function-s-expects-s-argument-s-but-s-argum","errorCode":null,"errorMessage":"Function \"%s\" expects %s argument(s), but %s argument(s) were provided.","messagePattern":"Function \"(.+?)\" expects (.+?) argument\\(s\\), but (.+?) argument\\(s\\) were provided\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/fact/chart/PhabricatorChartFunctionArgumentParser.php","lineNumber":127,"sourceCode":"  }\n\n  public function parseArguments() {\n    $have_count = count($this->rawArguments);\n    $want_count = count($this->argumentMap);\n\n    if ($this->haveAllArguments) {\n      if ($this->repeatableArgument) {\n        if ($want_count > $have_count) {\n          throw new Exception(\n            pht(\n              'Function \"%s\" expects %s or more argument(s), but only %s '.\n              'argument(s) were provided.',\n              $this->getFunctionArgumentSignature(),\n              $want_count,\n              $have_count));\n        }\n      } else if ($want_count !== $have_count) {\n        throw new Exception(\n          pht(\n            'Function \"%s\" expects %s argument(s), but %s argument(s) were '.\n            'provided.',\n            $this->getFunctionArgumentSignature(),\n            $want_count,\n            $have_count));\n      }\n    }\n\n    while ($this->unparsedArguments) {\n      $argument = array_shift($this->unparsedArguments);\n      $name = $argument->getName();\n\n      if (!$this->unconsumedArguments) {\n        throw new Exception(\n          pht(\n            'Function \"%s\" expects at least %s argument(s), but only %s '.\n            'argument(s) were provided.',","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/fact/chart/PhabricatorChartFunctionArgumentParser.php#L109-L145","documentation":"PhabricatorChartFunctionArgumentParser::parseArguments() enforces an exact argument count when no argument is repeatable: the number of raw arguments must equal the number of declared arguments. Any mismatch throws this Exception with the signature, expected count, and provided count.","triggerScenarios":"Invoking a fixed-arity chart function (e.g. one declared argument like 'constant') with a different number of arguments — zero, or two-plus — via a dictionary argument list or direct parser use.","commonSituations":"Extra arguments silently appended by dynamic list building; missing arguments from unset parameters; specs written against an older signature; treating fixed-arity functions as variadic.","solutions":["Match the count exactly — the message states how many arguments the function expects.","Trim or fill the argument list before construction based on the function's newArguments() declaration.","Validate counts per function name when building specs from user input.","Update stored specs after function signatures change between versions."],"exampleFix":"// before\n$fn = array('constant'); // 'constant' expects exactly 1 argument -> Exception\n\n// after\n$fn = array('constant', 1);","handlingStrategy":"validation","validationCode":"$expected = count($function->newArguments());\nif (count($raw_arguments) !== $expected) {\n  throw new Exception(\n    sprintf('Expected %d arguments, got %d', $expected, count($raw_arguments)));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match fixed-arity functions exactly — no extra, no missing arguments.","After version upgrades, review chart function signatures your specs depend on.","Log the raw argument list alongside parse errors when specs come from users."],"tags":["phabricator","facts","chart","argument-count","parser","php"],"backgroundTag":"argument-count-mismatch","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}