phacility/phabricator · error · Exception
Trying to construct a dataset of type "%s", but this type is
Error message
Trying to construct a dataset of type "%s", but this type is unknown. Supported types are: %s.
What it means
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.
Source
Thrown at src/applications/fact/chart/PhabricatorChartDataset.php:43
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getDatasetTypeKey')
->execute();
}
final public static function newFromDictionary(array $map) {
PhutilTypeSpec::checkMap(
$map,
array(
'type' => 'string',
'functions' => 'list<wild>',
));
$types = self::getAllDatasetTypes();
$dataset_type = $map['type'];
if (!isset($types[$dataset_type])) {
throw new Exception(
pht(
'Trying to construct a dataset of type "%s", but this type is '.
'unknown. Supported types are: %s.',
$dataset_type,
implode(', ', array_keys($types))));
}
$dataset = id(clone $types[$dataset_type]);
$functions = array();
foreach ($map['functions'] as $map) {
$functions[] = PhabricatorChartFunction::newFromDictionary($map);
}
$dataset->setFunctions($functions);
return $dataset;
}
View on GitHub (pinned to 5720a38cfe)
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.
Example fix
// before $dataset = PhabricatorChartDataset::newFromDictionary(array( 'type' => 'my-dataset', // not registered -> Exception 'functions' => $functions, )); // after $types = PhabricatorChartDataset::getAllDatasetTypes(); $type = isset($types['my-dataset']) ? 'my-dataset' : 'fact-count-dataset'; $dataset = PhabricatorChartDataset::newFromDictionary(array( 'type' => $type, 'functions' => $functions, ));
Defensive patterns
Strategy: validation
Validate before calling
$types = PhabricatorChartDataset::getAllDatasetTypes();
if (!isset($types[$map['type']])) {
// reject or substitute before calling newFromDictionary()
throw new Exception('Unsupported dataset type: '.$map['type']);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Attempting to build function "%s" from dictionary, but that
- Value for "fact-key" argument must be a string, got %s.
- Fact key "%s" is not a known fact key.
- Value for "function" argument must be a function definition,
- Value for "function" argument must be a natural list, not a
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/791a8aed1c3ef007.
Report an issue: GitHub.