c60812dd154dc99e8045db2d617ea969c26a28a2
max
  Wed Jul 8 08:07:55 2026 -0700
cart: treat an empty position value the same as unset, refs #37794

cartGetPosition only fell back to the assembly default position when the
cart position was NULL or the literal string "default". A stale empty
"position=" value (e.g. hgTracks?position=, or a position carried over from
a different assembly via a db= link) is returned verbatim as "" by
cartUsualString, so it slipped past that check and made hgTracks abort with
"Please go back and enter a coordinate range...". Treat an empty string like
unset so we fall back to the default position instead of crashing.

diff --git src/hg/lib/cart.c src/hg/lib/cart.c
index 19181c4a8a7..4b35a71452f 100644
--- src/hg/lib/cart.c
+++ src/hg/lib/cart.c
@@ -4034,32 +4034,34 @@
 	    }
 	}
     else
 	{
 	position = defaultPosition; // no value was set
 	}
     }
     
 if (position == NULL)
     {
     position = windowsToAscii(cloneString(cartUsualString(cart, "position", NULL)));
     }
 
 /* default if not set at all, as would happen if it came from a URL with no
  * position. Otherwise tell them to go back to the gateway. Also recognize
- * "default" as specifying the default position. */
-if (((position == NULL) || sameString(position, "default"))
+ * "default" as specifying the default position. An empty string is treated the
+ * same as unset (e.g. a stale "position=" left in the cart, or carried over
+ * from another assembly), so we fall back to the default rather than crashing. */
+if ((isEmpty(position) || sameString(position, "default"))
     && (defaultPosition != NULL))
     position = cloneString(defaultPosition);
 
 if (!gotCart)
     {
     cartSetBoolean(lastDbPosCart, "virtMode", FALSE);
     cartSetString(lastDbPosCart, "virtModeType", "default");
     cartSetString(lastDbPosCart, "lastVirtModeType", "default");
     cartSetString(lastDbPosCart, "position", position);
     cartSetString(lastDbPosCart, "nonVirtPosition", position);
     cartSetString(lastDbPosCart, "lastVirtModeExtra", "");
     }
 
 if (pLastDbPosCart)
     *pLastDbPosCart = lastDbPosCart;