phacility/phabricator · error · Exception
Query key "%s" does not correspond to a valid query.
Error message
Query key "%s" does not correspond to a valid query.
What it means
In buildQueryFromRequest() (used by every generated `<app>.search` Conduit method), when the request supplies a non-empty 'queryKey' that is neither a builtin key (like 'all' or 'open') nor a loadable PhabricatorSavedQuery row, a plain Exception is thrown. Query keys come from saved/named queries in the UI; the lookup is scoped to the current viewer, so a valid key owned by another user also resolves to nothing and fails here.
Source
Thrown at src/applications/search/engine/PhabricatorApplicationSearchEngine.php:1150
}
public function buildConduitResponse(
ConduitAPIRequest $request,
ConduitAPIMethod $method) {
$viewer = $this->requireViewer();
$query_key = $request->getValue('queryKey');
if ($query_key === null || !strlen($query_key)) {
$saved_query = new PhabricatorSavedQuery();
} else if ($this->isBuiltinQuery($query_key)) {
$saved_query = $this->buildSavedQueryFromBuiltin($query_key);
} else {
$saved_query = id(new PhabricatorSavedQueryQuery())
->setViewer($viewer)
->withQueryKeys(array($query_key))
->executeOne();
if (!$saved_query) {
throw new Exception(
pht(
'Query key "%s" does not correspond to a valid query.',
$query_key));
}
}
$constraints = $request->getValue('constraints', array());
if (!is_array($constraints)) {
throw new Exception(
pht(
'Parameter "constraints" must be a map of constraints, got "%s".',
phutil_describe_type($constraints)));
}
$fields = $this->getSearchFieldsForConduit();
foreach ($fields as $key => $field) {
if (!$field->getConduitParameterType()) {View on GitHub (pinned to 5720a38cfe)
Solutions
- List the user's valid keys first: call the app's `<app>.search` with no queryKey or fetch `user.query` style saved queries; simplest is to open the saved query in the UI and copy the queryKey from its URL.
- If the key belongs to another user, re-create the saved query under the account making the Conduit call, or use builtin keys ('all', 'open', 'authored') which are always valid.
- Stop passing the key entirely and send explicit 'constraints' in the Conduit request instead - constraints are stable and independent of user-saved state.
- Check for typos: keys are case-sensitive and alphanumeric.
Example fix
// before
{
"method": "maniphest.search",
"params": { "queryKey": "OthrUsersKey" }
}
// after: express the same filter with constraints
{
"method": "maniphest.search",
"params": { "constraints": { "statuses": ["open"], "projects": ["infra"] } }
} Defensive patterns
Strategy: validation
Validate before calling
// Validate a query key before using it
$builtin = $engine->getBuiltinQueries();
if (!isset($builtin[$query_key])) {
$saved = id(new PhabricatorSavedQueryQuery())
->setViewer($viewer)
->withQueryKeys(array($query_key))
->executeOne();
if (!$saved) { $query_key = null; } // fall back to defaults/constraints
} Type guard
function isValidQueryKey($engine, $viewer, $key) { return $engine->isBuiltinQuery($key) || (bool)id(new PhabricatorSavedQueryQuery())->setViewer($viewer)->withQueryKeys(array($key))->executeOne(); } Try / catch
try {
$saved = $engine->buildQueryFromRequest($request);
} catch (Exception $ex) {
// degrade to default query rather than failing the whole API call
$request->setValue('queryKey', null);
$saved = $engine->buildQueryFromRequest($request);
} Prevention
- Prefer explicit constraints over saved queryKeys in integrations
- Store query keys in configuration and validate them after each Phabricator upgrade
- Remember saved queries are per-user: integration users need their own saved queries
When it happens
Trigger: Conduit call `maniphest.search { "queryKey": "Xyz" }` where 'Xyz' is typo'd, belongs to another user, was deleted (user removed the saved query), or is a builtin key the engine does not expose (isBuiltinQuery() false for that engine). Also custom code calling buildSavedQueryFromBuiltin()/buildQueryFromRequest directly.
Common situations: Scripts hardcoding a saved-query key after its owner deleted or renamed it; sharing API snippets between accounts (saved queries are per-user); passing an engine-internal query key that is not marked builtin for that application; copy-pasting the query parameter from a Diffusion URL instead of the actual queryKey.
Related errors
- Parameter "constraints" must be a map of constraints, got "%
- API Method "%s" defines a disallowed parameter, "%s". This p
- API Method "%s" does not define these parameters: %s.
- Conduit API method "%s" does not exist.
- When creating a new Drydock blueprint via the Conduit API, y
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/ae7d7cdcbbc15c3a.
Report an issue: GitHub.