diff --git a/src/applications/conduit/parametertype/ConduitListParameterType.php b/src/applications/conduit/parametertype/ConduitListParameterType.php --- a/src/applications/conduit/parametertype/ConduitListParameterType.php +++ b/src/applications/conduit/parametertype/ConduitListParameterType.php @@ -3,6 +3,17 @@ abstract class ConduitListParameterType extends ConduitParameterType { + private $allowEmptyList = true; + + public function setAllowEmptyList($allow_empty_list) { + $this->allowEmptyList = $allow_empty_list; + return $this; + } + + public function getAllowEmptyList() { + return $this->allowEmptyList; + } + protected function getParameterValue(array $request, $key) { $value = parent::getParameterValue($request, $key); @@ -27,6 +38,13 @@ pht('Expected a list, but value is an object.')); } + if (!$value && !$this->getAllowEmptyList()) { + $this->raiseValidationException( + $request, + $key, + pht('Expected a nonempty list, but value is an empty list.')); + } + return $value; } diff --git a/src/applications/conduit/parametertype/ConduitParameterType.php b/src/applications/conduit/parametertype/ConduitParameterType.php --- a/src/applications/conduit/parametertype/ConduitParameterType.php +++ b/src/applications/conduit/parametertype/ConduitParameterType.php @@ -61,7 +61,11 @@ protected function raiseValidationException(array $request, $key, $message) { // TODO: Specialize this so we can give users more tailored messages from // Conduit. - throw new Exception($message); + throw new Exception( + pht( + 'Error while reading "%s": %s', + $key, + $message)); } diff --git a/src/applications/search/field/PhabricatorIDsSearchField.php b/src/applications/search/field/PhabricatorIDsSearchField.php --- a/src/applications/search/field/PhabricatorIDsSearchField.php +++ b/src/applications/search/field/PhabricatorIDsSearchField.php @@ -24,7 +24,8 @@ } protected function newConduitParameterType() { - return new ConduitIntListParameterType(); + return id(new ConduitIntListParameterType()) + ->setAllowEmptyList(false); } } diff --git a/src/applications/search/field/PhabricatorPHIDsSearchField.php b/src/applications/search/field/PhabricatorPHIDsSearchField.php --- a/src/applications/search/field/PhabricatorPHIDsSearchField.php +++ b/src/applications/search/field/PhabricatorPHIDsSearchField.php @@ -24,7 +24,8 @@ } protected function newConduitParameterType() { - return new ConduitPHIDListParameterType(); + return id(new ConduitPHIDListParameterType()) + ->setAllowEmptyList(false); } } diff --git a/src/applications/search/field/PhabricatorSearchDatasourceField.php b/src/applications/search/field/PhabricatorSearchDatasourceField.php --- a/src/applications/search/field/PhabricatorSearchDatasourceField.php +++ b/src/applications/search/field/PhabricatorSearchDatasourceField.php @@ -22,7 +22,8 @@ protected function newConduitParameterType() { if (!$this->conduitParameterType) { - return new ConduitStringListParameterType(); + return id(new ConduitStringListParameterType()) + ->setAllowEmptyList(false); } return $this->conduitParameterType;