phacility/phabricator · error · Exception
Query "%s" does not support a builtin order "%s". Supported
Error message
Query "%s" does not support a builtin order "%s". Supported orders are: %s.
What it means
Thrown by PhabricatorCursorPagedPolicyAwareQuery::setOrder() when the requested order key is not present in getBuiltinOrderAliasMap() for the concrete query class. Builtin orders are the named, ready-made sort orders each application query defines (with aliases); the exception message lists every supported key, so it is self-describing.
Source
Thrown at src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php:892
*
* This is a high-level method which selects an ordering from a predefined
* list of builtin orders, as provided by @{method:getBuiltinOrders}. These
* options are user-facing and not exhaustive, but are generally convenient
* and meaningful.
*
* You can also use @{method:setOrderVector} to specify a low-level ordering
* across individual orderable columns. This offers greater control but is
* also more involved.
*
* @param string Key of a builtin order supported by this query.
* @return this
* @task order
*/
public function setOrder($order) {
$aliases = $this->getBuiltinOrderAliasMap();
if (empty($aliases[$order])) {
throw new Exception(
pht(
'Query "%s" does not support a builtin order "%s". Supported orders '.
'are: %s.',
get_class($this),
$order,
implode(', ', array_keys($aliases))));
}
$this->builtinOrder = $aliases[$order];
$this->orderVector = null;
return $this;
}
/**
* Set a grouping order to apply before primary result ordering.
*View on GitHub (pinned to 5720a38cfe)
Solutions
- Read the exception message: it enumerates the supported orders for the exact query class — pick one of those
- Whitelist user-supplied sort keys against array_keys($query->getBuiltinOrderAliasMap()) before calling setOrder()
- For custom orderings, define the columns in getOrderableColumns() and use setOrderVector() instead
Example fix
// before
$query->setOrder($user_supplied_order);
// after: whitelist before applying
$aliases = $query->getBuiltinOrderAliasMap();
if (isset($aliases[$user_supplied_order])) {
$query->setOrder($user_supplied_order);
} else {
$query->setOrder('id');
} Defensive patterns
Strategy: validation
Validate before calling
// Whitelist against the query's own alias map before calling setOrder().
$aliases = $query->getBuiltinOrderAliasMap();
if (!isset($aliases[$order])) {
$order = 'id'; // safe default present on virtually all queries
}
$query->setOrder($order); Type guard
function isValidBuiltinOrder(PhabricatorCursorPagedPolicyAwareQuery $query, $order) {
return isset($query->getBuiltinOrderAliasMap()[$order]);
} Prevention
- Never pass user input straight to setOrder(); validate against getBuiltinOrderAliasMap() first
- When copying query code between applications, re-check that the target query supports the same orders
When it happens
Trigger: Calling setOrder('priority') on a query class whose builtin orders are only e.g. 'name', 'age', 'id'; using an alias only supported by a different query class; passing null or a typo'd key.
Common situations: Copy-pasting sort logic between query classes that support different orders; upgrading Phabricator when a builtin order is renamed or removed; constructing queries dynamically from user input without whitelisting.
Related errors
- This query ("%s") does not support sorting by order key "%s"
- Order vector "%s" is invalid: the last column in an order mu
- Order vector "%s" is invalid: only the last column in an ord
- Event queries which generate ghost events must include eithe
- Specify one or more queries to export with "--query".
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/befa48136e7a0f34.
Report an issue: GitHub.