c3788110e8d865774fff8197cf5b47350472ba64
chmalee
  Tue Aug 4 11:26:55 2026 -0700
Fix hubSpace hook error handling and nested hub path handling, refs #37964

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

diff --git src/hg/hgHubConnect/hooks/hooklib.c src/hg/hgHubConnect/hooks/hooklib.c
index 6c4caf6cb62..23d5bc3bcc7 100644
--- src/hg/hgHubConnect/hooks/hooklib.c
+++ src/hg/hgHubConnect/hooks/hooklib.c
@@ -52,36 +52,36 @@
 }
 
 char *normalizeParentDir(char *parentDir)
 /* Return parentDir with any surrounding whitespace trimmed off, or NULL if it was NULL.
  * The pre-create and pre-finish hooks each build paths from this metadata value
  * independently, so they have to normalize it identically or they end up disagreeing
  * about which directory the upload belongs in */
 {
 if (parentDir == NULL)
     return NULL;
 return trimSpaces(cloneString(parentDir));
 }
 
 boolean isValidParentDir(char *parentDir)
 /* Return TRUE if every '/' separated component of parentDir holds only alphanumeric,
- * period or underscore characters. NULL or empty means the top level of the user's
- * directory, which is allowed. Mirrors the same named check in hgMyData.js, which the
- * browser does first, but hubtools and any other tus client come straight here */
+ * period or underscore characters. NULL or empty is invalid, every upload belongs to
+ * a hub. Mirrors the same named check in hgMyData.js, which the browser does first,
+ * but hubtools and any other tus client come straight here */
 {
 if (isEmpty(parentDir))
-    return TRUE;
+    return FALSE;
 if (startsWith("/", parentDir) || endsWith(parentDir, "/"))
     return FALSE;
 int maxSeps = 256;
 char *pathArr[maxSeps];
 char *copy = cloneString(parentDir);
 int numChops = chopString(copy, "/", pathArr, maxSeps);
 int i = 0;
 for (; i < numChops; i++)
     {
     char *component = pathArr[i];
     if (isEmpty(component) || sameString(component, ".") || sameString(component, ".."))
         return FALSE;
     char *c = component;
     for (; *c != '\0'; c++)
         {