38576ff088798cb5e90741256ed0b5b20fde8346
hiram
  Wed Mar 4 16:43:03 2026 -0800
Claude recommended this change to the hub connection to avoid the error of a stale errorMessage in the hubStatus table

diff --git src/hg/hubApi/apiUtils.c src/hg/hubApi/apiUtils.c
index 182dec444f9..290741aef86 100644
--- src/hg/hubApi/apiUtils.c
+++ src/hg/hubApi/apiUtils.c
@@ -264,34 +264,40 @@
 *nameReturn = namesReturn;
 *typeReturn = typesReturn;
 *jsonTypes = jsonReturn;
 return columnCount;
 }
 
 struct trackHub *errCatchTrackHubOpen(char *hubUrl)
 /* use errCatch around a trackHub open in case it fails */
 {
 struct trackHub *hub = NULL;
 struct errCatch *errCatch = errCatchNew();
 if (errCatchStart(errCatch))
     {
     char *errMessage;
     unsigned hubId = hubFindOrAddUrlInStatusTable(NULL, hubUrl, &errMessage);
+    /* this hubFromIdNoAbort() call will update the hub status error message
+     *    if it has recovered from previous errors.
+     */
+    struct hubConnectStatus *hubStatus = hubFromIdNoAbort(hubId);
     
     // if we got an error, throw error
-    if (errMessage != NULL)
-        errAbort("%s", errMessage);
+    if (NULL == hubStatus)	/* this should not happen */
+        errAbort("could not find hub %u in status table", hubId);
+    if (!isEmpty(hubStatus->errorMessage))
+        errAbort("%s", hubStatus->errorMessage);
 
     // use hubId in hubName
     char buffer[4096];
     safef(buffer, sizeof buffer, "hub_%d", hubId);
     hub = trackHubOpen(hubUrl, buffer);
     }
 errCatchEnd(errCatch);
 if (errCatch->gotError)
     {
     apiErrAbort(err404, err404Msg, "error opening hubUrl: '%s', '%s'", hubUrl,  errCatch->message->string);
     }
 errCatchFree(&errCatch);
 return hub;
 }