Skip to content

Clone: fall back to SSH when an HTTPS remote fails auth and a key is present - #3

Merged
webdevcody merged 1 commit into
AgentSystemLabs:mainfrom
Shironex:fix/clone-ssh-fallback
Jun 3, 2026
Merged

webdevcody merged 1 commit into
AgentSystemLabs:mainfrom
Shironex:fix/clone-ssh-fallback

Conversation

@Shironex

@Shironex Shironex commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Problem

When a repo is selected from local disk, Mission Control derives the clone remote from its origin. That origin can be HTTPS or SSH, depending on how the user has the repo configured on their machine. If it's an HTTPS URL but the sandbox is provisioned with SSH auth only (a key under ~/.ssh), the clone fails — git never uses an SSH key for an https:// remote — and the provisioned key is never used:

fatal: could not read Username for 'https://github.com': terminal prompts disabled

Fix

In GitRpc.clone, when an HTTPS clone fails with a credentials error and a private key exists under ~/.ssh, derive the equivalent SSH remote (git@host:owner/repo.git) and retry once. Surgical:

  • Public repos still clone over HTTPS (no auth failure → no fallback).
  • Non-auth failures (repo-not-found, network) surface unchanged.
  • Remotes that already carry credentials aren't silently switched.

deriveSshFallbackRemote is a pure, unit-tested function; GitRpc gains an injectable sshDir (defaulting to ~/.ssh, matching SshRpc).

Testing

6 unit tests added (GitHub, .git suffix, GitLab subgroups, non-auth failure, no-key, SSH/credentialed/host-root rejection). typecheck, lint, git-rpc tests, and build pass.

Mission Control derives the clone remote from the selected repo's origin, which is commonly an HTTPS URL, while a sandbox is typically provisioned with SSH auth only. Git never uses an SSH key for an https:// remote, so cloning a private repo fails with 'could not read Username for https://github.com: terminal prompts disabled'.

When an HTTPS clone fails with a credentials error AND a private key is present under ~/.ssh, derive the equivalent SSH remote (git@host:owner/repo.git) and retry once. Surgical by design: public repos still clone over HTTPS (no auth failure, no fallback); non-auth failures (repo-not-found, network) surface as-is; URLs that already carried credentials are not silently switched. deriveSshFallbackRemote is a pure, unit-tested function; GitRpc gains an injectable sshDir (defaulting to ~/.ssh, matching SshRpc).

Root cause also worth fixing upstream in Mission Control (send an SSH remote when the sandbox uses SSH auth, or support an HTTPS token); this is the agent-side safety net.
@webdevcody
webdevcody merged commit 1c9e2de into AgentSystemLabs:main Jun 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants