From 310dc847002154858629b6efc104c431d2681086 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 23 Nov 2026 04:47:17 +0000 Subject: [PATCH 1/2] test(github): a secondary remote with a host URL rejects must not break GitHub resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reproduces #41221: gitHubApiHostForRemote throws TypeError: Invalid URL for git@nas.08:…, git@08:…, git@node.256:… and git@[2001:db8::1]:… remotes. Co-Authored-By: Claude Opus 5.5 --- .../server/gitHubRepositoryResolution.test.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts b/packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts index 3447c3a1be2a..2fd05d1dd071 100644 --- a/packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts +++ b/packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts @@ -168,6 +168,30 @@ describe("gitHubApiHostForRemote", () => { ); assert.strictEqual(gitHubApiHostForRemote("git@gitlab.com:a/b.git"), null); }); + + it("ignores a secondary remote whose host is not a valid URL host", () => { + for (const url of [ + "git@nas.08:team/repo.git", + "git@08:team/repo.git", + "git@node.256:team/repo.git", + "git@[2001:db8::1]:team/repo.git", + ]) { + const remotes = [ + "origin\tgit@github.com:pingdotgg/t3code.git (fetch)", + `backup\t${url} (fetch)`, + ].join("\n"); + assert.deepStrictEqual( + resolveGitHubRepository({ + remotes, + resolved: "", + hostHint: undefined, + defaultHost: "github.com", + }), + { host: "github.com", locator: { host: "github.com", owner: "pingdotgg", name: "t3code" } }, + url, + ); + } + }); }); describe("github.com- SSH aliases", () => { From 443771fec6e6f88f9bf7aaa87e1ae5e08499090a Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 23 Nov 2026 04:51:13 +0000 Subject: [PATCH 2/2] fix(github): a remote host URL rejects no longer breaks GitHub resolution gitHubApiHostForRemote now treats a remote whose host WHATWG URL rejects (an SSH alias like nas.08, a bracketed IPv6 SCP host) as non-GitHub instead of throwing TypeError: Invalid URL. Fixes #41221 Co-Authored-By: Claude Opus 5.5 --- .../src/server/gitHubRepositoryResolution.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/source-control-github/src/server/gitHubRepositoryResolution.ts b/packages/source-control-github/src/server/gitHubRepositoryResolution.ts index e42e428d9d99..cfd36b6c0276 100644 --- a/packages/source-control-github/src/server/gitHubRepositoryResolution.ts +++ b/packages/source-control-github/src/server/gitHubRepositoryResolution.ts @@ -166,7 +166,9 @@ function apiHostForSshAlias(host: string): string | null | undefined { export function gitHubApiHostForRemote(remoteUrl: string): string | null { const remote = parseGitRemoteHost(remoteUrl); if (remote === null) return null; - const host = new URL(`https://${remote.host}`).host.toLowerCase(); + const parsed = URL.parse(`https://${remote.host}`); + if (parsed === null) return null; + const host = parsed.host.toLowerCase(); if (isSshRemoteUrl(remoteUrl)) { const aliased = apiHostForSshAlias(host); if (aliased !== undefined) return aliased;