fix(source-control): explain clone failures #9831
Closedlnieuwenhuis(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/9831/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/sourceControl/SourceControlRepositoryService.ts line 45Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -21,6 +22,21 @@22+import { detectSourceControlProviderFromRemoteUrl } from "@t3tools/shared/sourceControl";23+2124 import { ServerConfig } from "../config.ts";2225 import { expandHomePathWith } from "../pathExpansion.ts";2326 import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";2427 import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";2528 const isSourceControlRepositoryError = Schema.is(SourceControlRepositoryError);262930+function cloneFailureDetail(stderr: string): string {31+ if (/host key verification failed/iu.test(stderr)) {32+ return "SSH could not verify the source control host. Add its host key to known_hosts and try again.";33+ }34+ if (/permission denied \(publickey(?:,[^)]+)?\)/iu.test(stderr)) {35+ return "SSH authentication failed. Add an SSH key to your source control account and try again.";36+ }37+ if (38+ /authentication failed|http basic: access denied|could not read username|terminal prompts disabled/iu.test(39+ stderr,40+ )41+ ) {42+ return "HTTPS authentication failed. Configure Git credentials for the source control host and try again.";apps/server/src/sourceControl/SourceControlRepositoryService.ts line 63Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -26,0 +31,21 @@31+ if (/host key verification failed/iu.test(stderr)) {32+ return "SSH could not verify the source control host. Add its host key to known_hosts and try again.";33+ }34+ if (/permission denied \(publickey(?:,[^)]+)?\)/iu.test(stderr)) {35+ return "SSH authentication failed. Add an SSH key to your source control account and try again.";36+ }37+ if (38+ /authentication failed|http basic: access denied|could not read username|terminal prompts disabled/iu.test(39+ stderr,40+ )41+ ) {42+ return "HTTPS authentication failed. Configure Git credentials for the source control host and try again.";43+ }44+ if (/could not resolve (?:host|hostname)/iu.test(stderr)) {45+ return "The source control host could not be resolved. Check your network or VPN connection and try again.";46+ }47+ if (/connection (?:timed out|refused)|failed to connect/iu.test(stderr)) {48+ return "Git could not connect to the source control host. Check your network or VPN connection and try again.";49+ }50+ if (/repository not found|could not read from remote repository/iu.test(stderr)) {51+ return "The repository could not be read. Check that it exists and that your Git credentials have access.";
- apps/server/src/sourceControl/SourceControlRepositoryService.ts line 252OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -199,5 +232,21 @@199232 args: ["clone", remoteUrl, preparedDestination.directoryName],233+ allowNonZeroExit: true,200234 timeoutMs: 120_000,201235 maxOutputBytes: 256 * 1024,202236 });203237238+ if (cloneResult.exitCode !== 0) {239+ const detail = cloneFailureDetail(cloneResult.stderr);240+ return yield* new SourceControlRepositoryError({241+ operation: "cloneRepository",242+ provider,243+ detail,244+ cause: new GitCommandError({245+ operation: "SourceControlRepositoryService.cloneRepository",246+ command: "git",247+ cwd: preparedDestination.parentPath,248+ argumentCount: 3,249+ exitCode: cloneResult.exitCode,250+ stdoutLength: cloneResult.stdout.length,251+ stderrLength: cloneResult.stderr.length,252+ detail,
- apps/server/src/sourceControl/SourceControlRepositoryService.ts lines 218 to 221Resolvedby lnieuwenhuis(GitHub profile, opens in a new tab)@@ -174,4 +216,7 @@174216 const preparedDestination = yield* prepareDestination(input.destinationPath);175217 let repository: SourceControlRepositoryInfo | null = null;176218 let remoteUrl = input.remoteUrl?.trim() ?? null;177- let provider: SourceControlProviderKind = input.provider ?? "unknown";219+ let provider: SourceControlProviderKind =220+ input.provider ??221+ (remoteUrl ? detectSourceControlProviderFromRemoteUrl(remoteUrl)?.kind : null) ??222+ "unknown";
juliusmarminge added labelsmacroscope-review
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
maria-rcks closed this
Sign in to join this conversation.


cursor[bot](GitHub profile, opens in a new tab) reviewed
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.