Skip to content

[deploy] Deployment to maven central randomly threw MavenCentralAPIException 401 Unauthorized, which killed the task #1757

@fprochazka

Description

@fprochazka

Actual Behaviour

I don't know what caused it because it seems like a fluke of https://central.sonatype.com/api/v1/publisher, but IMHO it should be handled anyway. But as you can see, the credentials are not incorrect, otherwise the upload.bundle step would not pass and neither would the first 4 checks of publish.deployment

[INFO]  Deploying Maven artifacts
[INFO]    [maven] Deploying all staged artifacts
[INFO]      [mavenCentral] Deploying to sonatype
[INFO]      [mavenCentral] Verifying prerequisites
[INFO]      [mavenCentral] Verifying POMs
[INFO]      [mavenCentral] Signing key FDC1B69A9BFA044 expires at 2034-11-10T15:41:28
[INFO]      [mavenCentral] Checking if key FDC1B69A9BFA044 has been published
[WARN]      [mavenCentral] Key FDC1B69A9BFA044 was NOT found as published
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids-hibernate-63/0.3.2/typed-ids-hibernate-63-0.3.2.module
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids-hibernate-63/0.3.2/typed-ids-hibernate-63-0.3.2.jar
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids/0.3.2/typed-ids-0.3.2.pom
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids/0.3.2/typed-ids-0.3.2.module
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids-hibernate-63/0.3.2/typed-ids-hibernate-63-0.3.2.pom
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids-hibernate-63/0.3.2/typed-ids-hibernate-63-0.3.2-sources.jar
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids/0.3.2/typed-ids-0.3.2.jar
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids-hibernate-63/0.3.2/typed-ids-hibernate-63-0.3.2-javadoc.jar
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids/0.3.2/typed-ids-0.3.2-sources.jar
[INFO]      [sign] build/staging-deploy/org/framefork/typed-ids/0.3.2/typed-ids-0.3.2-javadoc.jar
[INFO]      [mavenCentral]  - org.framefork-typed-ids-0.3.2-bundle.zip
[INFO]      [mavenCentral] maven.central.upload.bundle
[INFO]      [mavenCentral] Attempt 1 of 101
[INFO]      [mavenCentral] maven.central.publish.deployment
[INFO]      [mavenCentral] Attempt 1 of 101
[INFO]      [mavenCentral] Attempt 2 of 101
[INFO]      [mavenCentral] Attempt 3 of 101
[INFO]      [mavenCentral] Attempt 4 of 101
[INFO]      [mavenCentral] Attempt 5 of 101
[INFO]  Writing output properties to build/jreleaser/output.properties
Error:  JReleaser failed after 03:47 m
Caused by: org.jreleaser.sdk.mavencentral.MavenCentralException: Unexpected error
	at org.jreleaser.sdk.mavencentral.MavenCentral.wrap(MavenCentral.java:166)
	at org.jreleaser.sdk.mavencentral.MavenCentral.status(MavenCentral.java:120)
	at org.jreleaser.sdk.mavencentral.MavenCentral.lambda$waitForState$4(MavenCentral.java:174)
	at dev.failsafe.Functions.lambda$toCtxSupplier$11(Functions.java:243)
	at dev.failsafe.Functions.lambda$get$0(Functions.java:46)
	at dev.failsafe.internal.RetryPolicyExecutor.lambda$apply$0(RetryPolicyExecutor.java:74)
	at dev.failsafe.SyncExecutionImpl.executeSync(SyncExecutionImpl.java:187)
	... 137 more
Caused by: org.jreleaser.sdk.mavencentral.api.MavenCentralAPIException: 401: Unauthorized
	at org.jreleaser.sdk.mavencentral.MavenCentral$MavenCentralErrorDecoder.decode(MavenCentral.java:272)
	at feign.InvocationContext.decodeError(InvocationContext.java:133)
	at feign.InvocationContext.proceed(InvocationContext.java:80)
	at feign.RedirectionInterceptor.intercept(RedirectionInterceptor.java:46)
	at feign.ResponseInterceptor.lambda$apply$2(ResponseInterceptor.java:68)
	at feign.ResponseHandler.handleResponse(ResponseHandler.java:69)
	at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:109)
	at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:53)
	at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:104)
	at jdk.proxy5/jdk.proxy5.$Proxy147.status(Unknown Source)
	at org.jreleaser.sdk.mavencentral.MavenCentral.lambda$status$0(MavenCentral.java:123)
	at org.jreleaser.sdk.mavencentral.MavenCentral.wrap(MavenCentral.java:158)
	... 143 more

Full stacktrace at https://github.com/framefork/typed-ids/actions/runs/11802112348/job/32877025386

Expected Behaviour

I think that the jreleaser should remember that the token worked, and in case that the API returns 401 or 403 after it has seen the token work at least once, it should instead just retry.

Also, when I look at the deployments on https://central.sonatype.com/publishing/deployments, its showing a deployment status. I think it would be nice if the [mavenCentral] Attempt X of Y would also print the status, e.g.

...
[INFO]      [mavenCentral] Attempt 3 of 101 (PUBLISHING)
[INFO]      [mavenCentral] Attempt 4 of 101 (PUBLISHING)
[INFO]      [mavenCentral] Attempt 5 of 101 (Status checking failed with '401: Unauthorized', retrying anyway)
[INFO]      [mavenCentral] Attempt 6 of 101 (PUBLISHING)
...

Environment Information

  • Operating System: Ubuntu 22.04.5
  • JReleaser Version: 1.15.0
  • JDK Version: Java_Temurin-Hotspot_jdk/21.0.5-11/x64

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreleasedIssue has been released

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions