diff --git a/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
--- a/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
+++ b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
@@ -26,7 +26,7 @@
 
     // If the user is querying by monogram explicitly, like "O123", do an ID
     // search. Otherwise, do an ngram substring search.
-    if (preg_match('/^[oO]\d+\z/', $raw_query)) {
+    if ($raw_query && preg_match('/^[oO]\d+\z/', $raw_query)) {
       $id = trim($raw_query, 'oO');
       $id = (int)$id;
       $query->withIDs(array($id));
diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
--- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
+++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
@@ -2449,7 +2449,7 @@
     PhabricatorSearchNgrams $index,
     $value) {
 
-    if (strlen($value)) {
+    if (phutil_nonempty_string($value)) {
       $this->ngrams[] = array(
         'index' => $index,
         'value' => $value,