Fall back to anonymous JAR download on 4xx when Maven credentials are rejected#8158
Draft
Jammy-Louie wants to merge 1 commit into
Draft
Fall back to anonymous JAR download on 4xx when Maven credentials are rejected#8158Jammy-Louie wants to merge 1 commit into
Jammy-Louie wants to merge 1 commit into
Conversation
When Maven settings.xml credentials are rejected by the remote repository (401/403), retry the JAR download without authentication. Mirrors `MavenPomDownloader.requestAsAuthenticatedOrAnonymous()` and Apache Maven's behavior, so anonymous-accessible artifacts resolve even when configured credentials are invalid. Also fixes two nits observed during troubleshooting: - local cache filename was missing the hyphen before the classifier (`foo-1.0.0recipes.jar` → `foo-1.0.0-recipes.jar`) - download error message omitted the classifier
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.
Summary
MavenArtifactDownloadernow retries the JAR download anonymously whensettings.xmlcredentials are rejected by the remote repository (4xx), mirroringMavenPomDownloader.requestAsAuthenticatedOrAnonymous(). Credentials are applied first, so existing authenticated downloads against private repositories are unchanged and the anonymous attempt is only a fallback.Fix
LocalMavenArtifactCachecache filename missing the hyphen before the classifier (foo-1.0.0recipes.jar→foo-1.0.0-recipes.jar).Include the classifier in the
MavenDownloadingExceptionmessage so artifact coordinates are complete during troubleshooting.Split from the first commit of Try Maven downloads anonymously first, retry with credentials on 4xx #7447, to land this with minimal risk to existing behavior. A follow-up PR will mirror Apache Maven's anonymous-first behavior.
Test plan
fallsBackToAnonymousWhenServerReturns401fallsBackToAnonymousWhenCredentialsRejecteddownloadDependencies/downloadDependenciesWithClassifier