{"record":{"id":"c7781372d8711ff1","repo":"bmad-code-org/BMAD-METHOD","slug":"failed-to-clone-parsed-cloneurl-refsuffix","errorCode":null,"errorMessage":"Failed to clone ${parsed.cloneUrl}${refSuffix}: ${error_.message}","messagePattern":"Failed to clone (.+?)(.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"tools/installer/modules/custom-module-manager.js","lineNumber":496,"sourceCode":"      const fetchSpinner = await createSpinner();\n      fetchSpinner.start(`Cloning ${displayName}${effectiveVersion ? ` @ ${effectiveVersion}` : ''}...`);\n      try {\n        if (effectiveVersion) {\n          execSync(`git clone --depth 1 --branch ${quoteCustomRef(effectiveVersion)} \"${parsed.cloneUrl}\" \"${repoCacheDir}\"`, {\n            stdio: ['ignore', 'pipe', 'pipe'],\n            env: gitEnv({ GIT_TERMINAL_PROMPT: '0' }),\n          });\n        } else {\n          execSync(`git clone --depth 1 \"${parsed.cloneUrl}\" \"${repoCacheDir}\"`, {\n            stdio: ['ignore', 'pipe', 'pipe'],\n            env: gitEnv({ GIT_TERMINAL_PROMPT: '0' }),\n          });\n        }\n        fetchSpinner.stop(`Cloned ${displayName}`);\n      } catch (error_) {\n        fetchSpinner.error(`Failed to clone ${displayName}`);\n        const refSuffix = effectiveVersion ? `@${effectiveVersion}` : '';\n        throw new Error(`Failed to clone ${parsed.cloneUrl}${refSuffix}: ${error_.message}`);\n      }\n    }\n\n    // Record the resolved SHA for the manifest writer.\n    let resolvedSha = null;\n    try {\n      resolvedSha = execSync('git rev-parse HEAD', { cwd: repoCacheDir, stdio: 'pipe', env: gitEnv() }).toString().trim();\n    } catch {\n      // swallow — a non-git repo (local path) wouldn't reach here anyway\n    }\n    // Best-effort: capture the remote default branch name so channel marker\n    // metadata for \"next\" reflects the actual tracked ref (not always \"main\").\n    let defaultRef = 'main';\n    if (!effectiveVersion) {\n      try {\n        const symbolic = execSync('git symbolic-ref --short refs/remotes/origin/HEAD', {\n          cwd: repoCacheDir,\n          stdio: 'pipe',","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/bmad-code-org/BMAD-METHOD/blob/b70486b9bdcb0a404d329e2a763b57964e7f1360/tools/installer/modules/custom-module-manager.js#L478-L514","documentation":"Thrown by cloneRepo() inside the git clone catch block when execSync('git clone ...') fails for a remote URL. The error message includes the clone URL, optional @version suffix, and the underlying git error message. This is the primary network/repository-access failure path for custom module cloning.","triggerScenarios":"The repository URL is wrong or doesn't exist; network is down; the branch/tag specified via @version or pinOverride doesn't exist on the remote; authentication is required but GIT_TERMINAL_PROMPT is set to 0; a firewall blocks the connection; the git binary is not installed.","commonSituations":"Private repo without credentials configured; typo in the repo URL; the requested tag was deleted; SSH key not set up for git@ URLs; corporate proxy blocks HTTPS git; git not on PATH.","solutions":["Verify the repository URL is correct and accessible (try git clone manually).","If using SSH, ensure your SSH key is added and the host is in known_hosts.","If using HTTPS to a private repo, configure credentials (credential helper or token in the URL).","Verify the branch/tag name in the @version suffix exists on the remote.","Check network connectivity and proxy settings."],"exampleFix":"// before\nawait mgr.cloneRepo('https://github.com/org/wrong-repo.git@nonexistent-tag');\n\n// after — verify URL and tag manually first\n// $ git ls-remote --tags https://github.com/org/repo.git\nawait mgr.cloneRepo('https://github.com/org/repo.git@v1.2.3');","handlingStrategy":"retry","validationCode":"// Pre-flight check: verify the URL is reachable\nconst { execSync } = require('child_process');\n\nfunction canReachRepo(url) {\n  try {\n    execSync(`git ls-remote --exit-code \"${url}\" HEAD`, { stdio: 'ignore', timeout: 15000 });\n    return true;\n  } catch {\n    return false;\n  }\n}\n\nif (!canReachRepo(url)) {\n  throw new Error('Repository is not reachable. Check the URL, network, and credentials.');\n}","typeGuard":null,"tryCatchPattern":"const MAX_RETRIES = 3;\nfor (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {\n  try {\n    await mgr.cloneRepo(url, options);\n    break;\n  } catch (e) {\n    if (e.message.startsWith('Failed to clone') && attempt < MAX_RETRIES) {\n      console.log(`Clone attempt ${attempt} failed, retrying...`);\n      await new Promise(r => setTimeout(r, 2000 * attempt));\n      continue;\n    }\n    throw e;\n  }\n}","preventionTips":["Verify the repository URL with 'git ls-remote' before installing.","Configure git credentials (SSH keys, credential helper, or token) for private repos.","Ensure git is installed and on PATH.","For corporate networks, configure git's http.proxy setting.","Use GITHUB_TOKEN for GitHub HTTPS auth to avoid interactive prompts."],"tags":["network","git","clone","authentication"],"backgroundTag":null,"analyzedSha":"b70486b9bdcb0a404d329e2a763b57964e7f1360","analyzedAt":"2026-08-13T01:21:12.247Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}