Skip to content

Fix Git provider resolution when the server host is a DNS alias - #7626

Draft
bentsherman wants to merge 1 commit into
masterfrom
fix/rewrite-origin
Draft

bentsherman wants to merge 1 commit into
masterfrom
fix/rewrite-origin

Conversation

@bentsherman

Copy link
Copy Markdown
Member

Closes #6921.

Draft, because the approach is still open. See the discussion on the issue.

Problem

The clone URL is never derived from the server entry in the scm file. Every provider except Azure returns whatever the API advertises: clone_url for GitHub and Gitea, http_url_to_repo for GitLab, links.clone[].href for both Bitbucket providers. A self-hosted server behind a CNAME reports its own canonical hostname, while the scm file holds the alias the user dialled.

That mismatch is written into the local Git config at clone time. On any later run validateProjectDir() asks guessHubProviderFromGitConfig() for the provider the clone came from, the lookup matches hostnames as exact strings, finds nothing, and aborts:

Can't find any configured provider for git server `<host>` -- Make sure to have specified it in your `scm` file.

Nothing is actually wrong at that point. The hub provider and the credentials have already been resolved from the URL on the command line.

Change

RepositoryProvider.getConfiguredCloneUrl() returns the clone URL with the configured host in place of the one the provider reported. Only the hostname is replaced, so scheme, port, user and path survive as the API gave them, and a rename, a redirect or a self-hosted path prefix is carried through untouched. Local and unparseable URLs are left alone, as is the case where the hosts already agree.

The three clone sites use it: LegacyRepositoryStrategy.getGitRepositoryUrl(), MultiRevisionRepositoryStrategy.createBareRepo() and MultiRevisionRepositoryStrategy.getGitRepositoryUrl(). For the multi-revision layout the bare repo's config is the one that matters, since getLocalGitConfig() reads it.

getCloneUrl() itself is left abstract on purpose. Out-of-tree providers implement it, so making it concrete with an abstract getCloneUrl0() underneath would leave those classes abstract and unloadable.

Worth a reviewer's attention

No call site passes an explicit remote to jgit, so pull and fetch both use the stored origin. After this change Nextflow fetches from the configured host on every later pull rather than the host the API advertised. For the aliased case that seems right, since the configured host is the one the user holds credentials for, but it is a change in which hostname gets dialled and not only in what the config file records.

Leaving a second clone URL method on the provider API means a caller can pick the wrong one and silently skip the rewrite. MultiRevisionRepositoryStrategyTest did exactly that and failed with InvalidRemoteException: Invalid URL null, since it mocks the provider and stubs getCloneUrl(). The stub is updated here.

This prevents the mismatch from being written. It does not repair a clone that already carries one, which stays broken until it is dropped and pulled again. Relaxing the check in validateProjectDir() so that an unrecognised host warns instead of aborting would cover those too, and the two changes are complementary. I did not include it here.

CodeCommit is unaffected: its configured server and its clone URL both derive from git-codecommit.<region>.amazonaws.com.

Tests

New cases in RepositoryProviderTest cover the rewrite across subgroup paths, a non-default port, user info in the URL, the no-op when the hosts agree, and local or unparseable URLs. ./gradlew :nextflow:test --tests 'nextflow.scm.*' is green and :plugins:nf-codecommit:compileGroovy builds.

Provider APIs report the clone URL using the host the Git server knows
itself by. When the host configured in the SCM file is a DNS alias of
that host the two disagree, so the remote URL recorded in the local Git
config cannot be matched back to any configured provider. Reusing the
project on a later run then aborts with "Can't find any configured
provider for git server".

Rewrite the clone URL to use the configured host, keeping the scheme,
port, user and path reported by the provider.

Closes #6921

Signed-off-by: Ben Sherman <bentshermann@gmail.com>
@netlify

netlify Bot commented Sep 15, 2026

Copy link
Copy Markdown

Deploy Preview for nextflow-docs ready!

Name Link
🔨 Latest commit b657f0e
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs/deploys/6aa9515890d2580008bcd40b
😎 Deploy Preview https://deploy-preview-7626--nextflow-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git server credentials cannot be found when resuming and the domain is aliased using a CNAME record.

1 participant