fix(source-control): explain clone failures - #5005
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved 0cb093b This PR improves error messaging for git clone failures by mapping stderr patterns to actionable, user-friendly messages. The changes are self-contained to error handling, don't alter core clone behavior, and include comprehensive tests. You can customize Macroscope's approvability policy. Learn more. |
Source-control clones currently collapse Git transport failures into a generic operation error. This leaves users unable to distinguish SSH host trust, SSH key authentication, HTTPS credentials, repository access, DNS, and network failures. Raw clone URLs also report the provider as unknown even when the host identifies GitHub, GitLab, Bitbucket, or Azure DevOps.
Keep cloning in the shared Git driver rather than delegating to provider CLIs. Both glab repo clone and gh repo clone ultimately invoke Git, while Bitbucket has no equivalent official CLI path; provider-specific cloning would split one operation across inconsistent implementations without fixing Git transport setup.
The clone service now captures nonzero Git results locally, maps common stderr signatures to actionable transport-safe messages, preserves structured Git failure metadata without sending raw stderr over RPC, and infers the provider from raw remote URLs. This applies uniformly to GitHub, GitLab, Bitbucket, Azure DevOps, self-hosted instances, and generic Git URLs.
Verification:
Generated with GPT-5.6 using the Codex harness in T3 Code.
Note
Medium Risk
Changes clone error handling and user-facing transport/auth messaging without altering credential storage, but misclassified stderr patterns could mislead users during setup failures.
Overview
Clone failures now return clear, transport-safe errors instead of a generic Git failure.
cloneRepositoryrunsgit clonewithallowNonZeroExit, then maps commonstderrpatterns (SSH host trust, publickey auth, HTTPS credentials, DNS, connectivity, repo access) to actionable messages viacloneFailureDetail. Raw stderr is not exposed over RPC; failures surface asSourceControlRepositoryErrorwith a nestedGitCommandError(exit code and lengths only).When only a remote URL is supplied, the provider is inferred with
detectSourceControlProviderFromRemoteUrlso errors can name GitHub/GitLab/etc. instead ofunknown.Tests cover the main stderr cases and assert
operation,provider,detail, and structuredcausefields.Reviewed by Cursor Bugbot for commit 0cb093b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
cloneRepositoryto return actionable error details on Git clone failurescloneFailureDetailinSourceControlRepositoryService.tsthat maps common Git clone stderr patterns (SSH key issues, auth failures, DNS errors, timeouts, repo not found) to human-readable messages.cloneRepositorynow captures the Git exit code viaallowNonZeroExit: trueand wraps non-zero exits in aSourceControlRepositoryErrorwith aGitCommandErrorcause, replacing raw error propagation.remoteUrlviadetectSourceControlProviderFromRemoteUrlwhen not explicitly supplied.Macroscope summarized 0cb093b.