{"record":{"id":"947dceb0e844269a","repo":"phacility/phabricator","slug":"attempting-to-build-function-s-from-dictionary","errorCode":null,"errorMessage":"Attempting to build function \"%s\" from dictionary, but that function is unknown. Known functions are: %s.","messagePattern":"Attempting to build function \"(.+?)\" from dictionary, but that function is unknown\\. Known functions are: (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/fact/chart/PhabricatorChartFunction.php","lineNumber":79,"sourceCode":"  }\n\n  final public function getKey() {\n    return $this->getFunctionLabel()->getKey();\n  }\n\n  final public static function newFromDictionary(array $map) {\n    PhutilTypeSpec::checkMap(\n      $map,\n      array(\n        'function' => 'string',\n        'arguments' => 'list<wild>',\n      ));\n\n    $functions = self::getAllFunctions();\n\n    $function_name = $map['function'];\n    if (!isset($functions[$function_name])) {\n      throw new Exception(\n        pht(\n          'Attempting to build function \"%s\" from dictionary, but that '.\n          'function is unknown. Known functions are: %s.',\n          $function_name,\n          implode(', ', array_keys($functions))));\n    }\n\n    $function = id(clone $functions[$function_name])\n      ->setArguments($map['arguments']);\n\n    return $function;\n  }\n\n  public function getSubfunctions() {\n    $result = array();\n    $result[] = $this;\n\n    foreach ($this->getFunctionArguments() as $argument) {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/fact/chart/PhabricatorChartFunction.php#L61-L97","documentation":"PhabricatorChartFunction::newFromDictionary() constructs a chart function from a dictionary with 'function' and 'arguments' keys. The function name is looked up in the registry of PhabricatorChartFunction subclasses; an unknown name throws this Exception and the message lists all known function names.","triggerScenarios":"Calling PhabricatorChartFunction::newFromDictionary(array('function' => $name, 'arguments' => ...)) where $name is not a key of PhabricatorChartFunction::getAllFunctions() — e.g. a typo, a renamed function, or a custom function class not loaded.","commonSituations":"Stored charts referencing chart functions removed/renamed across Phabricator versions; hand-written chart function dictionaries; custom chart function classes whose getFunctionName() changed; JSON specs authored externally with guessed function names.","solutions":["Use a function name from the list in the error message exactly (case-sensitive).","Check the function registry with PhabricatorChartFunction::getAllFunctions() to see the exact keys available in your version.","Rebuild the chart/spec that embeds the bad function name and re-save it.","If a custom function class stopped registering, verify it extends PhabricatorChartFunction and its class is loadable."],"exampleFix":"// before\n$fn = PhabricatorChartFunction::newFromDictionary(array(\n  'function' => 'sum', // unknown -> Exception\n  'arguments' => array(1, 2),\n));\n\n// after\n$known = PhabricatorChartFunction::getAllFunctions();\n$name = isset($known['sum']) ? 'sum' : 'constant';\n$fn = PhabricatorChartFunction::newFromDictionary(array(\n  'function' => $name,\n  'arguments' => array(1, 2),\n));","handlingStrategy":"validation","validationCode":"$functions = PhabricatorChartFunction::getAllFunctions();\nif (!isset($functions[$map['function']])) {\n  throw new Exception('Unsupported chart function: '.$map['function']);\n}\n$fn = PhabricatorChartFunction::newFromDictionary($map);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build function dictionaries only from keys of getAllFunctions().","Centralize chart-spec construction in one helper that validates names.","After upgrades, re-save custom charts so stored dictionaries match current function names."],"tags":["phabricator","facts","chart","function","unknown-type","php"],"backgroundTag":"unknown-chart-function","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}