ea82eeb86ad5cf92ddf795f2d6f9ce84e33e52d5 chmalee Wed Jul 29 11:20:16 2026 -0700 Stop hubApi /search from crashing on position matches and curated hub genomes. refs #37956 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> diff --git src/hg/hubApi/search.c src/hg/hubApi/search.c index a0695fae56e..862b1e6afae 100644 --- src/hg/hubApi/search.c +++ src/hg/hubApi/search.c @@ -40,30 +40,34 @@ if (category != NULL) { if (ret) slCat(&ret, category); else ret = category; } } return ret; } void getSearchResults(char *searchTerm, char *db, char *hubUrl, char *categories) /* Output search results for db, potentially limited by categories */ { initGenbankTableNames(db); +/* No cart is built for API requests, so nothing has attached the hub yet. Open it to + * register the assembly, position searches need its 2bit rather than a chromInfo table. */ +if (isNotEmpty(hubUrl)) + (void) errCatchTrackHubOpen(hubUrl); struct cart *bogusCart = cartOfNothing(); cartAddString(bogusCart, "db", db); hashTracksAndGroups(bogusCart, db); struct jsonWrite *jw = apiStartOutput(); struct searchCategory *searchCategoryList = NULL; if (isNotEmpty(categories)) searchCategoryList = makeCategsFromString(categories, db, bogusCart); else searchCategoryList = getAllCategories(bogusCart, db, hgFindGroupHash); struct hgPositions *hgp = NULL; jsonWriteString(jw, "genome", db); hgp = hgPositionsFind(db, searchTerm, "", "searchExample", bogusCart, FALSE, measureTiming, searchCategoryList); if (hgp) hgPositionsJson(jw, db, hgp, NULL); apiFinishOutput(0, NULL, jw);