03478e629ac21b1dc68b92ae7d993d1a7314cac2
jcasper
  Mon Sep 22 11:15:22 2025 -0700
hgTables needed help finding trackDb for hic custom tracks, refs #36389

diff --git src/hg/hgTables/mainPage.c src/hg/hgTables/mainPage.c
index a98856a432a..046b70160c8 100644
--- src/hg/hgTables/mainPage.c
+++ src/hg/hgTables/mainPage.c
@@ -757,31 +757,40 @@
     }
 
 if (curTrack == NULL)
     {
     struct trackDb *tdb = hTrackDbForTrack(database, curTable);
     struct trackDb *cTdb = hCompositeTrackDbForSubtrack(database, tdb);
     if (cTdb)
         curTrack = cTdb;
     else
         curTrack = tdb;
     isMaf = isMafTable(database, curTrack, curTable);
     }
 
 /* Table-specific options */
 if (isHicTable(curTable))
-    hicMainPageConfig(cart, hTrackDbForTrack(database,curTable));
+    {
+    // Seems like there should be a better way to do this, but I'm not clear what it is at the moment.
+    // TrackDb processing could probably use some refactoring.
+    struct trackDb *tdb = hTrackDbForTrack(database,curTable);
+    if (tdb == NULL)
+        tdb = findTdbForTable(database, curTrack, curTable, ctLookupName);
+    if (tdb == NULL)
+        errAbort("Unable to find trackDb structure for track; something is wrong");
+    hicMainPageConfig(cart, tdb);
+    }
 
 hPrintf("<tr><td><DIV style='background-color: #faf2bb; display:none; opacity:0.9; border: 1px solid #EEE; margin: 2px; padding: 4px' id='snpTablesNote'>"
         "<b>Note:</b> Most dbSNP and gnomAD variant tables are huge. Trying to download them through the Table Browser "
         "usually leads to a timeout.<br> "
         "Please see our <a href='../FAQ/FAQdownloads.html#snp'>Data Access FAQ</a> "
         "for information on how to download dbSNP data, or refer to the Data Access section of the dbSNP or gnomAD track documentation pages.</DIV></td></tr>");
 
 /* Region line */
 {
 printStep(stepNumber++);
 
 char *regionType;
 if (cartVarExists(cart, "hgFind.matches")) // coming back from a search
     regionType = cartUsualString(cart, hgtaRegionType, hgtaRegionTypeRange);
 else