{"record":{"id":"f6943a9f6cde904c","repo":"abhigyanpatwari/GitNexus","slug":"local-path-must-be-an-absolute-path","errorCode":null,"errorMessage":"local_path must be an absolute path","messagePattern":"local_path must be an absolute path","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/auto-sync/path-security.ts","lineNumber":108,"sourceCode":"    realRoot,\n    'Configured clone root realpath escaped its normalized path',\n  );\n  assertNotDangerousRoot(realRoot);\n  assertNotGitNexusInternalRoot(realRoot);\n  const quarantineRoot = path.join(getAutoSyncWatchDir(), 'quarantine');\n  await pruneQuarantineEntries(quarantineRoot);\n\n  return {\n    root: realRoot,\n    quarantineRoot,\n    quarantineRetentionDays: QUARANTINE_RETENTION_DAYS,\n  };\n}\n\nexport function normalizeConfiguredCloneRoot(localPath: string): string {\n  const value = localPath.trim();\n  if (!value) throw new Error('local_path is required');\n  if (!path.isAbsolute(value)) throw new Error('local_path must be an absolute path');\n  if (value.split(path.sep).includes('..')) {\n    throw new Error('local_path must be normalized and must not contain traversal segments');\n  }\n  const resolved = path.resolve(value);\n  if (resolved !== path.normalize(value)) {\n    throw new Error('local_path must be normalized and must not contain traversal segments');\n  }\n  return resolved;\n}\n\nexport async function quarantineAutoSyncPartial(\n  targetDir: string,\n  quarantineRoot: string,\n): Promise<string> {\n  await fs.mkdir(quarantineRoot, { recursive: true, mode: 0o700 });\n  const base = path.basename(targetDir);\n  const stamp = new Date().toISOString().replace(/[:.]/g, '-');\n  const destination = path.join(","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/auto-sync/path-security.ts#L90-L126","documentation":"normalizeConfiguredCloneRoot requires local_path to be an absolute path. Relative paths are ambiguous because they depend on the working directory of the auto-sync process, so they are rejected with 'local_path must be an absolute path' before any filesystem access.","triggerScenarios":"parseAutoSyncConfig receives a local_path like \"clones\" or \"./repos/x\" (no leading \"/\" on POSIX, no drive/root on Windows).","commonSituations":"Configs written for portability with relative paths, values copied from a terminal where the user was in the target directory, or Docker-relative assumptions.","solutions":["Replace the relative path with an absolute one (e.g. /home/user/clones).","If the value comes from an env var, resolve it to absolute form before writing config (e.g. $(pwd)/clones).","Re-run parseAutoSyncConfig to confirm validation passes."],"exampleFix":"// before (config)\nlocal_path: \"./clones\"\n// after (config)\nlocal_path: \"/home/dev/projects/clones\"","handlingStrategy":"validation","validationCode":"if (localPath.trim() && !path.isAbsolute(localPath.trim())) throw new Error('local_path must be an absolute path');","typeGuard":null,"tryCatchPattern":"try {\n  parseAutoSyncConfig(raw);\n} catch (err) {\n  if (err.message === 'local_path must be an absolute path') {\n    console.error('Provide local_path as an absolute path, e.g. ' + path.resolve(localPath));\n  } else throw err;\n}","preventionTips":["Anchor relative values at startup: path.resolve(process.cwd(), relative) before writing config.","Store absolute paths in config files; keep them environment-specific via env expansion.","Add a config check that asserts path.isAbsolute(local_path)."],"tags":["config","path","validation","auto-sync"],"backgroundTag":"invalid-config-value","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"}