{"record":{"id":"c65175854e07c3bd","repo":"abhigyanpatwari/GitNexus","slug":"clone-failed-and-partial-checkout-could-not-be-qua","errorCode":null,"errorMessage":"Clone failed and partial checkout could not be quarantined: ${safeTarget}","messagePattern":"Clone failed and partial checkout could not be quarantined: (.+?)","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/server/git-clone.ts","lineNumber":474,"sourceCode":"        ? buildBranchCloneArgs(url, safeTarget, options.branch)\n        : buildCloneArgs(url, safeTarget);\n      await runGitImpl(cloneArgs, undefined, {\n        token: options?.token,\n        url,\n        timeoutMs: options?.timeoutMs,\n      });\n      await assertPostRealpathContainment(cloneRoot, safeTarget);\n    } catch (err: unknown) {\n      if (options?.quarantineRoot) {\n        const partialExists = await fs.access(safeTarget).then(\n          () => true,\n          () => false,\n        );\n        if (partialExists) {\n          try {\n            await quarantineAutoSyncPartial(safeTarget, options.quarantineRoot);\n          } catch (quarantineError) {\n            throw new AggregateError(\n              [err, quarantineError],\n              `Clone failed and partial checkout could not be quarantined: ${safeTarget}`,\n            );\n          }\n        }\n      }\n      throw err;\n    }\n  }\n\n  return safeTarget;\n}\n\nasync function assertPreRealpathContainment(root: string, target: string): Promise<void> {\n  const realRoot = await fs.realpath(root);\n  const realParent = await fs.realpath(path.dirname(target));\n  const parentRel = path.relative(realRoot, realParent);\n  if (parentRel.startsWith('..') || path.isAbsolute(parentRel)) {","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/server/git-clone.ts#L456-L492","documentation":"After a clone failure, cloneOrPull tries to quarantine a partial checkout via quarantineAutoSyncPartial; if quarantine itself fails, the original clone error and the quarantine error are rethrown together as an AggregateError. This tells you the clone failed AND a broken partial checkout remains in place at safeTarget.","triggerScenarios":"The git clone subprocess fails (network, auth, bad branch) while a partial target directory exists, and quarantineAutoSyncPartial throws (e.g. quarantineRoot unwritable, permission denied moving the directory).","commonSituations":"Flaky network plus a read-only or full quarantine disk; permission mismatch on the clone root preventing the rename/move; concurrent processes holding the partial directory open; SELinux/container mount restrictions on moving directories.","solutions":["Fix the quarantine destination (check options.quarantineRoot exists and is writable) and retry.","Manually remove the partial checkout at safeTarget, then re-run the clone.","Read the AggregateError.errors array: address the underlying clone failure first, then the quarantine failure.","Check filesystem permissions and free space on both the clone root and quarantine root."],"exampleFix":"// before\nawait cloneOrPull({ url, targetDir });\n// after: inspect both wrapped errors, then clean up and retry\ntry {\n  await cloneOrPull({ url, targetDir, quarantineRoot: '/var/tmp/gnx-quarantine' });\n} catch (e) {\n  if (e instanceof AggregateError) console.error(e.errors);\n}","handlingStrategy":"try-catch","validationCode":"await fs.mkdir(quarantineRoot, { recursive: true });\nawait fs.access(quarantineRoot, (await import('node:fs')).constants.W_OK); // ensure quarantine is writable before cloning","typeGuard":null,"tryCatchPattern":"try {\n  await cloneOrPull(opts);\n} catch (err) {\n  if (err instanceof AggregateError && err.message.includes('could not be quarantined')) {\n    for (const inner of err.errors) console.error('clone/quarantine failure:', inner);\n    // clean up partial checkout manually, fix quarantineRoot, then retry\n  } else {\n    throw err;\n  }\n}","preventionTips":["Provision quarantineRoot with the same ownership/permissions as the clone root.","Monitor disk space on both clone and quarantine volumes.","Retry clones on transient network errors so partial states are less likely.","Unwrap and log AggregateError.errors individually — there are always two distinct causes."],"tags":["git","clone","filesystem","cleanup"],"backgroundTag":"git-command-failed","analyzedSha":"0d1aed942f0e8b5d3bac27519fff441aceea722d","analyzedAt":"2026-09-08T00:40:44.970Z","contentChangedAt":"2026-09-08T00:40:44.970Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}