chenhg5/cc-connect · error

%s: %w

Error message

%s: %w

What it means

gitClone runs `git clone <repoURL> <dest>` and, on failure, wraps git's combined stderr/stdout output around the returned error. The developer sees what git itself printed (e.g. 'fatal: repository not found') followed by the underlying exec error.

Source

Thrown at core/engine.go:17052

		remainder := url[idx+1:]
		parts := strings.Split(remainder, "/")
		if len(parts) > 0 {
			return parts[len(parts)-1]
		}
	}
	// Handle https://host/org/repo format
	parts := strings.Split(url, "/")
	if len(parts) > 0 {
		return parts[len(parts)-1]
	}
	return "workspace"
}

func gitClone(repoURL, dest string) error {
	cmd := exec.Command("git", "clone", repoURL, dest)
	output, err := cmd.CombinedOutput()
	if err != nil {
		return fmt.Errorf("%s: %w", strings.TrimSpace(string(output)), err)
	}
	return nil
}

// ── Context usage indicator ──────────────────────────────────

const modelContextWindow = 200_000 // generic fallback window for heuristic context estimates

func contextIndicatorText(inputTokens int) string {
	if inputTokens <= 0 {
		return ""
	}
	pct := inputTokens * 100 / modelContextWindow
	if pct > 100 {
		pct = 100
	}
	return fmt.Sprintf("[ctx: ~%d%%]", pct)
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read the prefixed git output in the error — it usually states the exact cause (auth, not found, exists)
  2. Verify the repo URL is reachable: git ls-remote <repoURL>
  3. Set up credentials (SSH key, token) for private repositories
  4. Ensure the destination directory does not already exist or is empty
  5. Install git in the runtime environment

Example fix

// before: no authentication configured
gitClone("git@github.com:org/private.git", dest)
// after: use an authenticated HTTPS URL or configure a deploy key
gitClone("https://x-access-token:<token>@github.com/org/private.git", dest)
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := exec.LookPath("git"); err != nil {
    return fmt.Errorf("git not installed")
}
if err := exec.Command("git", "ls-remote", repoURL).Run(); err != nil {
    return fmt.Errorf("repo unreachable: %w", err)
}
if _, err := os.Stat(dest); err == nil {
    return fmt.Errorf("destination %s already exists", dest)
}

Try / catch

if err := gitClone(repoURL, dest); err != nil {
    slog.Error("git clone failed", "repo", core.RedactToken(repoURL), "err", err)
    return err
}

Prevention

When it happens

Trigger: Calling gitClone where the git subprocess exits non-zero: unreachable or nonexistent repository URL, authentication failure on a private repo, destination directory already exists and is non-empty, no network access, or git binary not installed.

Common situations: Typo'd or renamed repo URL; missing deploy key / credentials for private repos; destination path already cloned; firewall blocking github.com; minimal container image without git installed.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/520ae60b1a34de75. Report an issue: GitHub.