Fix Git provider resolution when the server host is a DNS alias - #7626
Draft
bentsherman wants to merge 1 commit into
Draft
bentsherman wants to merge 1 commit into
bentsherman wants to merge 1 commit into
Conversation
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>
✅ Deploy Preview for nextflow-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6921.
Draft, because the approach is still open. See the discussion on the issue.
Problem
The clone URL is never derived from the
serverentry in thescmfile. Every provider except Azure returns whatever the API advertises:clone_urlfor GitHub and Gitea,http_url_to_repofor GitLab,links.clone[].hreffor both Bitbucket providers. A self-hosted server behind a CNAME reports its own canonical hostname, while thescmfile holds the alias the user dialled.That mismatch is written into the local Git config at clone time. On any later run
validateProjectDir()asksguessHubProviderFromGitConfig()for the provider the clone came from, the lookup matches hostnames as exact strings, finds nothing, and aborts: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()andMultiRevisionRepositoryStrategy.getGitRepositoryUrl(). For the multi-revision layout the bare repo's config is the one that matters, sincegetLocalGitConfig()reads it.getCloneUrl()itself is left abstract on purpose. Out-of-tree providers implement it, so making it concrete with an abstractgetCloneUrl0()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.
MultiRevisionRepositoryStrategyTestdid exactly that and failed withInvalidRemoteException: Invalid URL null, since it mocks the provider and stubsgetCloneUrl(). 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
serverand its clone URL both derive fromgit-codecommit.<region>.amazonaws.com.Tests
New cases in
RepositoryProviderTestcover 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:compileGroovybuilds.