8ba8a055a41e48f2e0f06803754544dd0089f4ec
chmalee
  Thu Oct 13 12:48:20 2022 -0700
explicitly return NULL if categories were asked for in hubApi but no search results for that category

diff --git src/hg/lib/hgFind.c src/hg/lib/hgFind.c
index cb57d62..8b75f1d 100644
--- src/hg/lib/hgFind.c
+++ src/hg/lib/hgFind.c
@@ -3655,30 +3655,34 @@
 if (singleSearch(db, term, limitResults, cart, hgp, measureTiming))
     return hgp;
 
 if (categories != NULL)
     {
     if (!matchesHgvs(cart, db, term, hgp, measureTiming))
         userDefinedSearch(db, term, limitResults, cart, hgp, categories, measureTiming);
     slReverse(&hgp->tableList);
     if (multiTerm)
         collapseSamePos(hgp);
     fixSinglePos(hgp);
     if (cart && hgp->singlePos && isNotEmpty(hgp->singlePos->highlight))
         cartSetString(cart, "addHighlight", hgp->singlePos->highlight);
     if (hgp->posCount > 0)
         return hgp;
+    else
+        // if categories was passed in we should explicitly return no results
+        // if there weren't any
+        return NULL;
     }
 
 /* Allow any search term to end with a :Start-End range -- also support stuff 
  * pasted in from BED (chrom start end) or SQL query (chrom | start | end).  
  * If found, strip it off and remember the start and end. */
 char *originalTerm = term;
 if ((canonicalSpec = 
         regexMatchSubstrNoCase(term, canonicalRangeExp, substrs, ArraySize(substrs))) ||
     (gbrowserSpec = 
         regexMatchSubstrNoCase(term, gbrowserRangeExp, substrs, ArraySize(substrs))) ||
     (lengthSpec = 
         regexMatchSubstrNoCase(term, lengthRangeExp, substrs, ArraySize(substrs))) ||
     regexMatchSubstrNoCase(term, bedRangeExp, substrs, ArraySize(substrs)) ||
     (singleBaseSpec =
 	regexMatchSubstrNoCase(term, singleBaseExp, substrs, ArraySize(substrs))) ||