0f2f66270dcd4603785850ee72d7d883ff68185b
braney
  Sun Sep 20 07:03:14 2026 -0700
asForDbTester: a GenArk accession must not be looked for in MySQL

asForDb() may need a database connection to fetch a track's autoSql.  The name
it is handed is usually an assembly, but on a quickLifted track it is the
SOURCE assembly, and for a GenArk that arrives as a bare accession with no
MySQL database of that name anywhere.  Without #38272's isGenArk test the CGI
does not return an empty field list, it dies, and the reader gets an error page
instead of a details page -- only for the combination of a quickLift and a
GenArk source, which is why it went unnoticed.

The last case is the discriminating one: a name that is neither a GenArk
accession nor a real database still aborts, which shows the GenArk case is let
through deliberately rather than by connection failures having stopped
mattering.  The abort message carries a MySQL error number and the server's own
wording, so what is pinned is whether the abort was about reaching a database
of that name, not the text.

Two things this test got wrong before it got them right, both recorded in its
header.  It has to run against a config that sets genarkHubPrefix, because
isGenArk answers through that prefix and says no when it is unset, so with a
developer's own hg.conf the GenArk case failed for a reason unrelated to the
fix.  And the accession is read from the genark table at run time, since naming
an assembly makes the test go red the day that assembly is dropped.

Also fixes the registry row for bedItemRgbTester, which moved to hg/cgilib and
whose row still named the old path -- caught by the registry's own check, which
is the first time it has failed for a real reason.

refs #38272, refs #38391

diff --git src/hg/lib/tests/makefile src/hg/lib/tests/makefile
index 52fea0e97e0..d5299d1aa3d 100644
--- src/hg/lib/tests/makefile
+++ src/hg/lib/tests/makefile
@@ -14,31 +14,31 @@
 	${BIN_DIR}/sessionDataTester \
 	${BIN_DIR}/trashDirTester \
 #	${BIN_DIR}/annoGratorTester \
 	${BIN_DIR}/binTest \
 	${BIN_DIR}/customTrackTester \
 	${BIN_DIR}/hgvsTester \
 	${BIN_DIR}/sqlCheck 
 
 ${BIN_DIR}/%: %.c ${MYLIBS}
 	@${MKDIR} ${BIN_DIR}
 	${CC} ${CC_PROG_OPTS} -o $@ $*.c ${MYLIBS} $L
 
 #test: binTest spDbTest hdbTest genePredTest pslReaderTest annoGratorTest customTrackTest hgvsTest
 test: binTest quickLiftTest sessionDataTest trashDirTest mallocTopPadTest \
 	hVarSubstHtmlTest dataVersionPathTest genarkLiftOverTest \
-	snapshotTypeTest sessionDirTest geoMirrorSelfTest spDbTest hdbTest genePredTest pslReaderTest customTrackTest hgvsTest
+	snapshotTypeTest sessionDirTest geoMirrorSelfTest asForDbTest spDbTest hdbTest genePredTest pslReaderTest customTrackTest hgvsTest
 	rm -r output
 	echo tested all
 
 mkdirs:
 	@${MKDIR} output ${BIN_DIR}
 
 loaders:
 	ln -sf ${CGI_BIN}/loader .
 
 spDbTest: ${BIN_DIR}/spDbTest mkdirs
 	${BIN_DIR}/spDbTest sp121210 Q9FFH7 > output/spDbTest
 	${BIN_DIR}/spDbTest sp121210 P29312 >> output/spDbTest
 	diff expected/spDbTest output/spDbTest
 
 hdbTest: ${BIN_DIR}/hdbTest mkdirs
@@ -146,21 +146,29 @@
 # WRITES to a central database, so it is pointed at hgcentralregress,
 # which exists for tests and which nothing else reads.  makeHgCentralRegress.sh creates it and
 # is safe to run every time.  login.cookieSalt is set because the sync signature is made with
 # it; the value is a test value and means nothing outside this run.
 hubSpaceKeysTest: mkdirs
 	${CC} ${CC_PROG_OPTS} -o ${BIN_DIR}/hubSpaceKeysTester hubSpaceKeysTester.c ${MYLIBS} $L
 	./makeHgCentralRegress.sh > /dev/null
 	echo "include ${HOME}/.hg.conf" > output/regress.conf
 	echo "central.db=hgcentralregress" >> output/regress.conf
 	echo "login.cookieSalt=testSaltForRegressRuns" >> output/regress.conf
 	HGDB_CONF=output/regress.conf ${BIN_DIR}/hubSpaceKeysTester > output/hubSpaceKeysTest
 	diff expected/hubSpaceKeysTest output/hubSpaceKeysTest
 # It runs as soon as central.user has UPDATE and DELETE on hgcentralregress; see
 # makeHgCentralRegress.sh for the grant.  Add it to the test target on that day.
 
+# The conf a CGI reads, not the developer's own: isGenArk() needs genarkHubPrefix, which is
+# set in the shared one.
+asForDbTest: mkdirs
+	${CC} ${CC_PROG_OPTS} -o ${BIN_DIR}/asForDbTester asForDbTester.c ${MYLIBS} $L
+	echo "include /usr/local/apache/cgi-bin/hg.conf" > output/genark.conf
+	HGDB_CONF=output/genark.conf ${BIN_DIR}/asForDbTester > output/asForDbTest 2>&1
+	diff expected/asForDbTest output/asForDbTest
+
 sqlCheck: ${BIN_DIR}/sqlCheck mkdirs
 	${MAKE} -f sqlCheck.mk test BIN_DIR=${BIN_DIR} OUT_DIR=output
 
 
 clean:
 	rm -rf *.o bin output *.tmp loader udcCache