From 382e2c32fc104baf6891df981f7d4932b9abd348 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 15 Apr 2019 11:48:07 -0700 Subject: [PATCH] When an invalid "constraints" parameter is provided to a "*.search" method, raise a more tailored error Summary: See . (The caller provided `constraints={...}` via cURL, but you can't mix JSON and HTTP parameters like that.) Test Plan: Called `curl 'http://local.phacility.com/api/maniphest.search?api.token=...&constraints=X'` (with a valid API token), got a more sensible error. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D20429 --- .../search/engine/PhabricatorApplicationSearchEngine.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index a89a017e85..4f5308fa28 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -1142,6 +1142,12 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject { } $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();