{"record":{"id":"331b92a34e9f21b1","repo":"phacility/phabricator","slug":"value-for-function-argument-must-be-a-list-with","errorCode":null,"errorMessage":"Value for \"function\" argument must be a list with a function name; got an empty list.","messagePattern":"Value for \"function\" argument must be a list with a function name; got an empty list\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/fact/chart/PhabricatorChartFunctionArgument.php","lineNumber":101,"sourceCode":"        if (!is_array($value)) {\n          throw new Exception(\n            pht(\n              'Value for \"function\" argument must be a function definition, '.\n              'formatted as a list, like: [fn, arg1, arg, ...]. Actual value '.\n              'is %s.',\n              phutil_describe_type($value)));\n        }\n\n        if (!phutil_is_natural_list($value)) {\n          throw new Exception(\n            pht(\n              'Value for \"function\" argument must be a natural list, not '.\n              'a dictionary. Actual value is \"%s\".',\n              phutil_describe_type($value)));\n        }\n\n        if (!$value) {\n          throw new Exception(\n            pht(\n              'Value for \"function\" argument must be a list with a function '.\n              'name; got an empty list.'));\n        }\n\n        $function_name = array_shift($value);\n\n        if (!is_string($function_name)) {\n          throw new Exception(\n            pht(\n              'Value for \"function\" argument must be a natural list '.\n              'beginning with a function name as a string. The first list '.\n              'item has the wrong type, %s.',\n              phutil_describe_type($function_name)));\n        }\n\n        $functions = PhabricatorChartFunction::getAllFunctions();\n        if (!isset($functions[$function_name])) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/fact/chart/PhabricatorChartFunctionArgument.php#L83-L119","documentation":"After confirming a 'function' argument is a natural list, PhabricatorChartFunctionArgument::newValue() requires the list to be non-empty because the first element is the function name. An empty array throws this Exception.","triggerScenarios":"Passing array() (or []) as a nested function definition, commonly from an empty optional parameter, an array_map over an empty set, or a default value that was never filled in.","commonSituations":"Building argument lists dynamically where a sub-expression produced no elements; empty request parameters flowing into chart construction; JSON specs containing [] as a function node.","solutions":["Omit the argument entirely if there is no nested function to apply.","Default empty optional values to a meaningful function (e.g. array('constant', 0)).","Filter empty arrays out of dynamically built argument lists before passing them to chart APIs.","Validate count($value) > 0 during spec construction."],"exampleFix":"// before\n$arguments[] = array(); // empty list -> Exception\n\n// after: omit empty nested functions\nif ($nested) {\n  $arguments[] = $nested;\n}","handlingStrategy":"validation","validationCode":"if (is_array($value) && !count($value)) {\n  // skip the argument or supply a meaningful default function\n  $value = array('constant', 0);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter empty lists out of dynamically built argument lists.","Default optional nested functions to an explicit function definition.","Check count($value) > 0 when composing specs programmatically."],"tags":["phabricator","facts","chart","argument-validation","empty-value","php"],"backgroundTag":"invalid-function-argument-format","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}