{"record":{"id":"afeac48e75951bd8","repo":"abhigyanpatwari/GitNexus","slug":"auto-sync-clone-root-is-not-a-directory-root","errorCode":null,"errorMessage":"auto-sync clone root is not a directory: ${root}","messagePattern":"auto-sync clone root is not a directory: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/auto-sync/path-security.ts","lineNumber":260,"sourceCode":"  let current = parsed.root;\n  const parts = root.slice(parsed.root.length).split(path.sep).filter(Boolean);\n  for (const part of parts) {\n    current = path.join(current, part);\n    let stat;\n    try {\n      stat = await fs.lstat(current);\n    } catch (err: unknown) {\n      if ((err as NodeJS.ErrnoException).code === 'ENOENT') break;\n      throw err;\n    }\n    if (stat.isSymbolicLink())\n      throw new Error(`Refusing symlink in auto-sync clone root path: ${current}`);\n  }\n}\n\nexport async function assertDirectoryOwnerAndPermissions(root: string): Promise<void> {\n  const stat = await fs.stat(root);\n  if (!stat.isDirectory()) throw new Error(`auto-sync clone root is not a directory: ${root}`);\n  // POSIX uid/mode have no meaning on Windows, and this runs on every tick for\n  // every project, so throwing here failed 100% of repos forever while `watch\n  // status` still read `running`. Skip the ownership assertions rather than the\n  // whole feature: the caller's other guards — dangerous-root rejection\n  // (including the Windows system roots), symlink refusal, realpath containment\n  // and the GitNexus-internal-root check — all still apply, and managed git runs\n  // with `core.hooksPath` pinned to the null device.\n  if (process.platform === 'win32') return;\n  if (typeof process.getuid === 'function' && stat.uid !== process.getuid()) {\n    throw new Error(`auto-sync clone root is owned by uid ${stat.uid}, not current process uid`);\n  }\n  const mode = stat.mode & 0o777;\n  const groupWritable = (mode & 0o020) !== 0;\n  const worldWritable = (mode & 0o002) !== 0;\n  if (worldWritable) {\n    throw new Error(`Refusing world-writable auto-sync clone root: ${root}`);\n  }\n  if (groupWritable) {","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/auto-sync/path-security.ts#L242-L278","documentation":"Thrown by assertDirectoryOwnerAndPermissions when fs.stat() on the clone root succeeds but stat.isDirectory() is false — the configured path exists as a regular file, socket, device node, or similar non-directory entry. Auto-sync needs a directory to clone repositories into, so it refuses to proceed rather than overwriting or writing alongside the existing file.","triggerScenarios":"Thrown at gitnexus/src/core/auto-sync/path-security.ts:260 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove or relocate the file currently occupying the clone-root path, then let auto-sync (re)create the directory","Point the configuration at an existing directory","Check for a stray lock file, log file, or typo that caused the path to be created as a file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0d1aed942f0e8b5d3bac27519fff441aceea722d","analyzedAt":"2026-09-08T00:40:44.970Z","contentChangedAt":"2026-09-08T00:40:44.970Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}