phacility/phabricator · error · PhabricatorTypeaheadInvalidTokenException
This datasource ("%s") can not evaluate the function "%s(...
Error message
This datasource ("%s") can not evaluate the function "%s(...)". What it means
After parsing a function token, the datasource verifies the function against its own getDatasourceFunctions() map. If the function is not defined for this datasource class, strict mode throws PhabricatorTypeaheadInvalidTokenException naming the datasource and the unsupported function.
Source
Thrown at src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php:500
} else {
$ok = preg_match('/^([^(]+)\((.*)\)\z/', $token, $matches);
}
if (!$ok) {
if (!$allow_partial) {
throw new PhabricatorTypeaheadInvalidTokenException(
pht(
'Unable to parse function and arguments for token "%s".',
$token));
}
return null;
}
$function = trim($matches[1]);
if (!$this->canEvaluateFunction($function)) {
if (!$allow_partial) {
throw new PhabricatorTypeaheadInvalidTokenException(
pht(
'This datasource ("%s") can not evaluate the function "%s(...)".',
get_class($this),
$function));
}
return null;
}
// TODO: There is currently no way to quote characters in arguments, so
// some characters can't be argument characters. Replace this with a real
// parser once we get use cases.
$argv = $matches[2];
$argv = trim($argv);
if (!strlen($argv)) {
$argv = array();
} else {View on GitHub (pinned to 5720a38cfe)
Solutions
- Check the datasource's function list via getDatasourceFunctions() and use only functions it defines.
- Replace the function token with a concrete value (resolve the PHID or submit the literal string).
- Switch to the datasource that actually implements the function (e.g. the project logical datasource for 'any()'/'not()').
- Catch PhabricatorTypeaheadInvalidTokenException and drop the unusable token.
Example fix
// before
$constraint = array('viewer()'); // on a datasource without 'viewer'
// after
$constraint = array($viewer->getPHID()); Defensive patterns
Strategy: validation
Validate before calling
// Only accept function tokens this datasource defines
$functions = $datasource->getDatasourceFunctions();
if (preg_match('/^([^(]+)\(/', $token, $m)) {
$function = strtolower(trim($m[1]));
if (empty($functions[$function])) {
// replace with a literal value or reject the constraint
$token = null;
}
} Try / catch
try {
$value = $datasource->evaluateTokens(array($token));
} catch (PhabricatorTypeaheadInvalidTokenException $ex) {
// drop the unusable token; warn the user if the constraint was required
} Prevention
- Check getDatasourceFunctions() on the concrete datasource before emitting function syntax.
- Do not copy function tokens between different form fields or datasources.
- After upgrades, re-verify that saved function tokens still exist in the current function map.
When it happens
Trigger: Feeding a token like 'viewer()' or 'any(open)' to a datasource that does not implement that function (e.g. a plain user datasource given a projects-logical function), or reusing a token produced by a different datasource's function datasource class.
Common situations: Conduit search constraints copying function syntax between field types; saved query tokens moved to a different form field; custom forms wired to the wrong datasource; function renamed or removed after an upgrade.
Related errors
- Unable to parse function and arguments for token "%s".
- Custom field class "%s" does not exist.
- Custom field class "%s" does not implement interface "%s".
- No custom field role specified.
- No custom field key specified.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/be6541f5f9193ac1.
Report an issue: GitHub.