{"record":{"id":"128caca0bbb19a0a","repo":"coleam00/Archon","slug":"failed-to-clone-repository-safeerr-message","errorCode":null,"errorMessage":"Failed to clone repository: ${safeErr.message}","messagePattern":"Failed to clone repository: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/handlers/clone.ts","lineNumber":393,"sourceCode":"  // Remove the empty source/ directory before cloning (git clone requires non-existent target)\n  try {\n    await rm(targetPath, { recursive: true });\n  } catch (error) {\n    const err = error as NodeJS.ErrnoException;\n    if (err.code !== 'ENOENT') {\n      throw error;\n    }\n  }\n\n  try {\n    // GIT_TERMINAL_PROMPT=0 turns any missing-creds scenario into an\n    // immediate, readable error instead of a hung stdin credential prompt.\n    await execFileAsync('git', ['clone', cloneUrl, targetPath], {\n      env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },\n    });\n  } catch (error) {\n    const safeErr = sanitizeError(error as Error);\n    throw new Error(`Failed to clone repository: ${safeErr.message}`);\n  }\n\n  // Add to git safe.directory\n  await execFileAsync('git', ['config', '--global', '--add', 'safe.directory', targetPath]);\n  getLog().debug({ path: targetPath }, 'safe_directory_added');\n\n  const result = await registerRepoAtPath(targetPath, `${ownerName}/${repoName}`, workingUrl);\n  getLog().info({ url: workingUrl, targetPath }, 'clone_completed');\n  return result;\n}\n\n/**\n * Register an existing local repository in the database (no git clone).\n */\nexport async function registerRepository(localPath: string): Promise<RegisterResult> {\n  // Validate path exists and is a git repo\n  try {\n    await execFileAsync('git', ['-C', localPath, 'rev-parse', '--git-dir']);","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/handlers/clone.ts#L375-L411","documentation":"cloneRepository runs `git clone` with GIT_TERMINAL_PROMPT=0 so credential prompts fail fast instead of hanging. Any git clone failure is sanitized (credentials stripped) and rethrown as 'Failed to clone repository: <reason>'.","triggerScenarios":"Calling cloneRepository when `git clone <cloneUrl> <targetPath>` exits non-zero: bad URL, nonexistent repo, missing/invalid credentials for a private repo, network failure, or existing non-empty target.","commonSituations":"Private repo without a configured credential helper or token; typo'd clone URL; no network access / proxy blocking github.com; SSH key not set up while using an SSH URL; repo deleted or renamed.","solutions":["Run `git clone <url>` manually to see the underlying git error","For private repos, configure credentials: `gh auth login` or a credential helper / deploy key","Verify the clone URL and that the repo exists and you have access","Check network/proxy connectivity to github.com; switch SSH URL to HTTPS if SSH keys are missing"],"exampleFix":"// before\nawait cloneRepository({ url: 'git@github.com:acme/private.git' });\n// after\n// gh auth login  (or use HTTPS URL with token)\nawait cloneRepository({ url: 'https://github.com/acme/private.git' });","handlingStrategy":"try-catch","validationCode":"await new Promise((res, rej) => execFile('git', ['ls-remote', cloneUrl], (e) => e ? rej(e) : res(null)));","typeGuard":null,"tryCatchPattern":"try { await cloneRepository(args); } catch (e) { if (e.message.startsWith('Failed to clone repository')) { console.error(e.message + '\\nCheck: URL correctness, credentials (gh auth login), and network access.'); } throw e; }","preventionTips":["Authenticate before cloning private repos (gh auth login or credential helper)","Pre-verify repo access with `git ls-remote <url>`","Use HTTPS URLs unless SSH keys are configured for the runtime user","Ensure network/proxy allows github.com from the execution environment"],"tags":["git","clone","authentication","network"],"backgroundTag":"git-clone-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}