{"record":{"id":"791a8aed1c3ef007","repo":"phacility/phabricator","slug":"trying-to-construct-a-dataset-of-type-s-but-th","errorCode":null,"errorMessage":"Trying to construct a dataset of type \"%s\", but this type is unknown. Supported types are: %s.","messagePattern":"Trying to construct a dataset of type \"(.+?)\", but this type is unknown\\. Supported types are: (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/fact/chart/PhabricatorChartDataset.php","lineNumber":43,"sourceCode":"    return id(new PhutilClassMapQuery())\n      ->setAncestorClass(__CLASS__)\n      ->setUniqueMethod('getDatasetTypeKey')\n      ->execute();\n  }\n\n  final public static function newFromDictionary(array $map) {\n    PhutilTypeSpec::checkMap(\n      $map,\n      array(\n        'type' => 'string',\n        'functions' => 'list<wild>',\n      ));\n\n    $types = self::getAllDatasetTypes();\n\n    $dataset_type = $map['type'];\n    if (!isset($types[$dataset_type])) {\n      throw new Exception(\n        pht(\n          'Trying to construct a dataset of type \"%s\", but this type is '.\n          'unknown. Supported types are: %s.',\n          $dataset_type,\n          implode(', ', array_keys($types))));\n    }\n\n    $dataset = id(clone $types[$dataset_type]);\n\n    $functions = array();\n    foreach ($map['functions'] as $map) {\n      $functions[] = PhabricatorChartFunction::newFromDictionary($map);\n    }\n    $dataset->setFunctions($functions);\n\n    return $dataset;\n  }\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/fact/chart/PhabricatorChartDataset.php#L25-L61","documentation":"PhabricatorChartDataset::newFromDictionary() rebuilds a chart dataset from a stored dictionary. After a PhutilTypeSpec::checkMap confirming 'type' is a string, it looks the type up in the registry built from PhabricatorChartDataset subclasses; an unregistered type raises this Exception, listing all supported type keys.","triggerScenarios":"Calling PhabricatorChartDataset::newFromDictionary(array('type' => ..., 'functions' => ...)) with a 'type' that is not a key of getAllDatasetTypes(). Typical with hand-built chart specifications, or rendering a stored chart whose dataset type class was removed or renamed between versions.","commonSituations":"Upgrading Phabricator and loading old chart data whose dataset class no longer exists; custom chart code constructing dictionaries with a guessed type name; copy-pasting a chart spec from documentation of a different version.","solutions":["Read the message: it enumerates every supported dataset type — pick one of those exact keys.","If the dictionary comes from a stored chart, rebuild/re-save the chart in the UI so it stores a current type.","If custom code builds the dictionary, dump PhabricatorChartDataset::getAllDatasetTypes() and align the key.","After a custom class rename, update or migrate stored chart data referencing the old key."],"exampleFix":"// before\n$dataset = PhabricatorChartDataset::newFromDictionary(array(\n  'type' => 'my-dataset', // not registered -> Exception\n  'functions' => $functions,\n));\n\n// after\n$types = PhabricatorChartDataset::getAllDatasetTypes();\n$type = isset($types['my-dataset']) ? 'my-dataset' : 'fact-count-dataset';\n$dataset = PhabricatorChartDataset::newFromDictionary(array(\n  'type' => $type,\n  'functions' => $functions,\n));","handlingStrategy":"validation","validationCode":"$types = PhabricatorChartDataset::getAllDatasetTypes();\nif (!isset($types[$map['type']])) {\n  // reject or substitute before calling newFromDictionary()\n  throw new Exception('Unsupported dataset type: '.$map['type']);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always source dataset type strings from getAllDatasetTypes() keys.","When persisting charts, store types your current version can rebuild.","Run a smoke-render of stored charts after upgrades to catch stale types early."],"tags":["phabricator","facts","chart","dataset","unknown-type","php"],"backgroundTag":"unknown-chart-dataset-type","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}