Skip to content

Fall back to anonymous JAR download on 4xx when Maven credentials are rejected#8158

Draft
Jammy-Louie wants to merge 1 commit into
mainfrom
maven-jar-auth-anonymous-fallback
Draft

Fall back to anonymous JAR download on 4xx when Maven credentials are rejected#8158
Jammy-Louie wants to merge 1 commit into
mainfrom
maven-jar-auth-anonymous-fallback

Conversation

@Jammy-Louie

@Jammy-Louie Jammy-Louie commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • MavenArtifactDownloader now retries the JAR download anonymously when settings.xml credentials are rejected by the remote repository (4xx), mirroring MavenPomDownloader.requestAsAuthenticatedOrAnonymous(). Credentials are applied first, so existing authenticated downloads against private repositories are unchanged and the anonymous attempt is only a fallback.

  • Fix LocalMavenArtifactCache cache filename missing the hyphen before the classifier (foo-1.0.0recipes.jarfoo-1.0.0-recipes.jar).

  • Include the classifier in the MavenDownloadingException message 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

  • fallsBackToAnonymousWhenServerReturns401
  • fallsBackToAnonymousWhenCredentialsRejected
  • downloadDependencies / downloadDependenciesWithClassifier

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants