{"record":{"id":"60949a2ad2d8ffd3","repo":"phacility/phabricator","slug":"function-s-expects-s-or-more-argument-s-but","errorCode":null,"errorMessage":"Function \"%s\" expects %s or more argument(s), but only %s argument(s) were provided.","messagePattern":"Function \"(.+?)\" expects (.+?) or more argument\\(s\\), but only (.+?) argument\\(s\\) were provided\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/fact/chart/PhabricatorChartFunctionArgumentParser.php","lineNumber":118,"sourceCode":"    return $this;\n  }\n\n  public function getAllArguments() {\n    return array_values($this->argumentMap);\n  }\n\n  public function getRawArguments() {\n    return $this->rawArguments;\n  }\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","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/fact/chart/PhabricatorChartFunctionArgumentParser.php#L100-L136","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n$arguments = array_filter($values); // drops 0 values -> too few args -> Exception\n\n// after\n$arguments = array_filter($values, function ($v) { return $v !== null; });","handlingStrategy":"validation","validationCode":"$declared = count($function->newArguments()); // or your known minimum\nif (count($raw_arguments) < $declared) {\n  throw new Exception('Too few arguments for chart function');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"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"}