{"record":{"id":"63a59a7882dd4061","repo":"phacility/phabricator","slug":"value-for-function-argument-must-be-a-function-d","errorCode":null,"errorMessage":"Value for \"function\" argument must be a function definition, formatted as a list, like: [fn, arg1, arg, ...]. Actual value is %s.","messagePattern":"Value for \"function\" argument must be a function definition, formatted as a list, like: \\[fn, arg1, arg, \\.\\.\\.\\]\\. Actual value is (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/fact/chart/PhabricatorChartFunctionArgument.php","lineNumber":84,"sourceCode":"\n        $facts = PhabricatorFact::getAllFacts();\n        $fact = idx($facts, $value);\n        if (!$fact) {\n          throw new Exception(\n            pht(\n              'Fact key \"%s\" is not a known fact key.',\n              $value));\n        }\n\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(","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/fact/chart/PhabricatorChartFunctionArgument.php#L66-L102","documentation":"For 'function' typed chart arguments, PhabricatorChartFunctionArgument::newValue() accepts either an existing PhabricatorChartFunction object or a list definition [fn, arg1, arg2, ...]. Any non-array value (string, number, null) throws this Exception, reporting the actual PHP type.","triggerScenarios":"Supplying a bare string function name ('sum') or scalar where a nested function definition list is required, e.g. arguments like array('sum', 1) nested inside another function's argument list where the inner value is not an array.","commonSituations":"Assuming the argument takes a function name string instead of a list; passing a null from an unset variable; JSON specs that inline scalars where nested functions are expected.","solutions":["Wrap nested functions as lists: use array('sum', 1, 2) or ['sum', 1, 2], not 'sum'.","Pass an existing PhabricatorChartFunction object if you already built one.","Validate structure before constructing: the value must be is_array().","Check for nulls introduced by optional request parameters feeding the argument list."],"exampleFix":"// before\n$arguments[] = 'constant'; // string where function definition expected -> Exception\n\n// after\n$arguments[] = array('constant', 100); // [fn, arg1, ...] list form","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function is_function_definition($value) {\n  return $value instanceof PhabricatorChartFunction || is_array($value);\n}","tryCatchPattern":null,"preventionTips":["Remember nested functions use the [fn, arg1, ...] list form, not a bare name.","Pass an already-built PhabricatorChartFunction object when in doubt.","Validate external spec shapes before handing them to chart APIs."],"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"}