{"record":{"id":"2c41521f17f02b38","repo":"phacility/phabricator","slug":"value-for-function-argument-must-be-a-natural-li","errorCode":null,"errorMessage":"Value for \"function\" argument must be a natural list, not a dictionary. Actual value is \"%s\".","messagePattern":"Value for \"function\" argument must be a natural list, not a dictionary\\. Actual value is \"(.+?)\"\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/fact/chart/PhabricatorChartFunctionArgument.php","lineNumber":93,"sourceCode":"\n        return $fact;\n      case 'function':\n        // If this is already a function object, just return it.\n        if ($value instanceof PhabricatorChartFunction) {\n          return $value;\n        }\n\n        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(","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/fact/chart/PhabricatorChartFunctionArgument.php#L75-L111","documentation":"A 'function' argument that is an array must be a natural list (zero-based sequential integer keys). PhabricatorChartFunctionArgument::newValue() rejects dictionaries or sparse arrays via phutil_is_natural_list(), reporting the actual type shape in the message.","triggerScenarios":"Passing an array with string keys (e.g. array('function' => 'sum', 'arguments' => array(1))) or a non-sequential key set where the [fn, arg1, ...] positional list form is required.","commonSituations":"Confusing the dictionary form used by newFromDictionary() with the list form used inside argument lists; hand-built PHP arrays with named keys; JSON objects where a JSON array was required.","solutions":["Use the positional list form: array('sum', 1, 2).","Do not use the 'function'/'arguments' dictionary shape for nested function arguments.","Call array_values($value) to re-index a sparse array into a natural list.","In JSON payloads, ensure nested function definitions are arrays, not objects."],"exampleFix":"// before\n$arguments[] = array(\n  'function' => 'sum',\n  'arguments' => array(1, 2),\n); // dictionary, not natural list -> Exception\n\n// after\n$arguments[] = array('sum', 1, 2); // natural list [fn, arg1, arg2]","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function is_natural_function_list($value) {\n  return is_array($value) && phutil_is_natural_list($value);\n}","tryCatchPattern":null,"preventionTips":["Never use the 'function'/'arguments' dictionary shape for nested function arguments.","In JSON specs, nested function definitions must be arrays, not objects.","Normalize sparse arrays with array_values() before use."],"tags":["phabricator","facts","chart","argument-validation","format-error","php"],"backgroundTag":"invalid-function-argument-format","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}