Repository navigation
Description
What I observed
gitHubApiHostForRemote (packages/source-control-github/src/server/gitHubRepositoryResolution.ts:166-175) calls new URL(\https://${remote.host}`).host.toLowerCase()on line 169 without atry/catch`.
Because resolveGitHubRepository (gitHubRepositoryResolution.ts:71-74) maps gitHubApiHostForRemote(remote.url) over every fetch remote from git remote -v, having any secondary remote that uses an IPv6 SCP URL (git@[2001:db8::1]:team/repo.git) or an OpenSSH Host alias whose last dot-separated label fails WHATWG URL's IPv4 check (git@nas.08:team/repo.git, git@08:team/repo.git, git@node.256:team/repo.git) throws an uncaught TypeError: Invalid URL and crashes GitHub repository/PR resolution for the entire repo — even when origin is a normal github.com remote.
parseGitRemoteHost (packages/source-control-core/src/shared/definition.ts:573-596) explicitly wraps its own new URL(\https://${host}`)intry/catchand returns{ remoteUrl, host, hostname }, so these valid SCP remotes reach gitHubApiHostForRemote` directly.
Reproduction
- Commit:
main @ 9d3054a7bb - Environment: macOS 27.2.1, Node v26.13.1, git 2.56.1
Run from the repo root (also reproduces identically with git@08:team/repo.git, git@node.256:team/repo.git, or git@[2001:db8::1]:team/repo.git):
node --experimental-strip-types -e '
import { execFileSync } from "node:child_process";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import {
resolveGitHubRepository,
} from "./packages/source-control-github/src/server/gitHubRepositoryResolution.ts";
const dir = mkdtempSync(join(tmpdir(), "repro-gh-"));
try {
execFileSync("git", ["init", "-q"], { cwd: dir });
execFileSync("git", ["remote", "add", "origin", "git@github.com:pingdotgg/t3code.git"], { cwd: dir });
execFileSync("git", ["remote", "add", "backup", "git@nas.08:team/repo.git"], { cwd: dir });
const remotes = execFileSync("git", ["remote", "-v"], { cwd: dir, encoding: "utf8" });
console.log(resolveGitHubRepository({ remotes, resolved: "", hostHint: undefined, defaultHost: "github.com" }));
} finally {
rmSync(dir, { recursive: true, force: true });
}
'Expected behavior
gitHubApiHostForRemote returns null for non-GitHub or unparseable remote hosts instead of throwing, and resolveGitHubRepository resolves origin to { host: "github.com", locator: { host: "github.com", owner: "pingdotgg", name: "t3code" } }.
Actual behavior
gitHubApiHostForRemote throws an uncaught TypeError: Invalid URL, aborting resolveGitHubRepository and causing an unhandled Effect defect across all five live call sites in GitHubSourceControlProvider.ts (resolveRepository, checkoutPullRequest, createsChangeRequestsIn, resolveRemoteWebHost, refineUnknownRemote).
Evidence
Stack trace from the command above:
TypeError: Invalid URL
at gitHubApiHostForRemote (packages/source-control-github/src/server/gitHubRepositoryResolution.ts:169:16)
at resolveGitHubRepository (packages/source-control-github/src/server/gitHubRepositoryResolution.ts:73:11)
Additional investigation
- How found: Property-based testing of external-format/source-control parsers, minimized to the plain Node +
gitsnippet above. - Verified: Confirmed on
origin/main(9d3054a7bb).GitHubSourceControlProviderinvokesgitHubApiHostForRemote/resolveGitHubRepositorysynchronously insideEffect.fnwithout catching defects at 5 call sites (resolveRepository,checkoutPullRequest,createsChangeRequestsIn,resolveRemoteWebHost,refineUnknownRemote). - Duplicate check: Searched open and closed issues/PRs for
gitHubApiHostForRemote,resolveGitHubRepository,TypeError: Invalid URL, andparseGitRemoteHost.- Open PR fix(source-control): read SCP-style remotes on IPv6 hosts #31917 fixes bracketed IPv6 in
SCP_REMOTE, but does not touchgitHubApiHostForRemote, so valid OpenSSH aliases likegit@nas.08:team/repo.gitstill throwTypeError: Invalid URLeven with fix(source-control): read SCP-style remotes on IPv6 hosts #31917 applied. - Open PR fix(github): keep gh's default repository when local remotes exist #34130 only skips hostless local/file remotes in
selectGitHubBaseRepository, notresolveGitHubRepository'smap(gitHubApiHostForRemote).
- Open PR fix(source-control): read SCP-style remotes on IPv6 hosts #31917 fixes bracketed IPv6 in
- Impact: Major for affected repos — any secondary backup/deploy/LAN remote with a numeric-suffix SSH alias or IPv6 SCP URL breaks all GitHub PR lookup, creation, listing, and checkout operations in that repo.
Activity