abhigyanpatwari/GitNexus · error · Error

Refusing unsafe auto-sync clone root: ${root}

Error message

Refusing unsafe auto-sync clone root: ${root}

What it means

Thrown by the auto-sync path-security guard assertNotDangerousRoot (called from resolveConfiguredCloneRoot) when the configured clone root exactly matches an entry in the DANGEROUS_ROOTS blocklist (system-critical directories such as filesystem root, /home, /tmp, /etc, and Windows system roots). It fires before any clone or pull runs, preventing auto-sync from writing repository content directly into an OS-critical directory and clobbering it with repo files.

Source

Thrown at gitnexus/src/core/auto-sync/path-security.ts:213

  }
  await Promise.all(
    [...byRepo.values()].flatMap((group) =>
      group
        // The timestamp is the leading fixed-width field, so a descending
        // string sort is newest-first.
        .sort((a, b) => (a < b ? 1 : a > b ? -1 : 0))
        .slice(QUARANTINE_MAX_ENTRIES_PER_REPO)
        .map(async (entry) => {
          await fs.rm(path.join(quarantineRoot, entry), { recursive: true, force: true });
          await fs.rm(path.join(quarantineRoot, `${entry}.README.txt`), { force: true });
        }),
    ),
  );
}

function assertNotDangerousRoot(root: string): void {
  if (root === path.resolve(getGlobalDir(), 'repos')) return;
  if (DANGEROUS_ROOTS.has(root)) throw new Error(`Refusing unsafe auto-sync clone root: ${root}`);
  for (const dangerousRoot of DANGEROUS_PARENT_ROOTS) {
    const rel = path.relative(dangerousRoot, root);
    if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) {
      throw new Error(`Refusing unsafe auto-sync clone root under ${dangerousRoot}: ${root}`);
    }
  }
  if (path.parse(root).root === root)
    throw new Error(`Refusing filesystem root as clone root: ${root}`);
}

function assertNotGitNexusInternalRoot(root: string): void {
  const gitnexusDir = path.resolve(getGlobalDir());
  const blocked = [
    path.join(gitnexusDir, 'groups'),
    path.join(gitnexusDir, 'indexes'),
    path.join(gitnexusDir, 'quarantine'),
    path.join(getAutoSyncWatchDir(gitnexusDir), 'quarantine'),
  ];

View on GitHub (pinned to 0d1aed942f)

Solutions

  1. Set the auto-sync clone root to a dedicated directory outside the DANGEROUS_ROOTS blocklist (e.g. the default <globalDir>/repos)
  2. Point the configuration at an empty, user-owned directory on a data volume
  3. Inspect the auto-sync config (config file or env var) for a typo that resolved the root to a system directory such as / or /home
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at gitnexus/src/core/auto-sync/path-security.ts:213 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-09-08). Data as JSON: /api/errors/f8cd404e72e1eaa8. Report an issue: GitHub.