Skip to content

fix(server): detect a recognized remote when origin's host is unknown - #41912

Closed
2SinceJuly wants to merge 1 commit into
pingdotgg:mainfrom
2SinceJuly:fix/34022-remote-provider-detection
Closed

2SinceJuly wants to merge 1 commit into
pingdotgg:mainfrom
2SinceJuly:fix/34022-remote-provider-detection

Conversation

@2SinceJuly

Copy link
Copy Markdown
Contributor

Problem

With more than one git remote, a repository whose origin is a self-hosted server that no source control integration recognizes resolves to the unknown provider, even when another remote points at github.com. Every later source control call then fails with No unknown source control provider is registered., so creating a pull request is impossible.

github  [email protected]:someuser/some-repo.git          (fetch/push)
origin  ssh://[email protected]/path-to-repos/some-repo.git (fetch/push)
remote1 ssh://[email protected]/path-to-repos/some-repo.git (fetch/push)

Reported in #34022 (0.1.9-nightly.20261110.4478, Linux).

selectProviderContext returns the remote named origin whenever any provider recognizes its URL — including the URL parser's unknown verdict — so the recognized github remote is never considered.

Change

In detectProviderContext, when the selected context is still unknown after refinement, fall back to the first remote whose host a registered integration does recognize, and refine that context instead. A remote named origin that a CLI does claim still wins, and a repository whose remotes are all unrecognized keeps today's behavior.

Scope

Bug fix only. Closes #34022.

Verification

Added two cases to apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts:

  • prefers a recognized remote over an unrecognized origin builds the report's remote set (unrecognized origin, github second) and asserts the handle resolves to github with remoteName: "github".
  • keeps a recognized origin over a recognized remote further down asserts the existing precedence is unchanged.

Ran the new test on the unmodified source to confirm it reproduces the bug:

FAIL  src/sourceControl/SourceControlProviderRegistry.test.ts > prefers a recognized remote over an unrecognized origin
AssertionError: expected 'unknown' to equal 'github'
Expected: "github"
Received: "unknown"
 ❯ src/sourceControl/SourceControlProviderRegistry.test.ts:269:12

With the fix, the whole file passes on current main (93318111):

Test Files  1 passed (1)
     Tests  17 passed (17)

vp check reports all changed files correctly formatted. Nothing else was checked: the fix is covered by the provider registry unit tests, and I did not create a pull request against a live multi-remote repository.

Claude Code.

selectProviderContext prefers a remote named origin even when no registered CLI recognizes its host, so a repository whose origin points at a self-hosted server resolves to the unknown provider and createChangeRequest fails with "No unknown source control provider is registered", while a second remote on github.com goes unused.

When the origin candidate refines to unknown, fall back to the first remote whose host a provider does recognize before asking the discovery CLIs about origin. An origin a CLI claims still wins.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 24, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for this. #34025 makes the same change and is the one being kept.

#34025 implements the same fallback while reusing the remote candidates already collected for provider selection. That keeps the fix smaller and avoids adding a second remote-recognition loop.

Your regression test preserving a recognized origin's priority is useful coverage that could be carried into the retained fix.

Closing as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Fail to detect source-control provider with multiple git remotes

2 participants