Skip to content

[deploy] Maven Snapshot URL paths are not normalized #1724

@andrewazores

Description

@andrewazores

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem (link to git repository is ideal)
  • Full description of the issue provided (see below)

Steps to Reproduce

Create a Maven project using JReleaser. As an example,

https://github.com/cryostatio/cryostat-core

with the configuration like

<profiles>
  <profile>
    <id>release</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.jreleaser</groupId>
          <artifactId>jreleaser-maven-plugin</artifactId>
          <version>${jreleaser-maven-plugin.version}</version>
          <inherited>false</inherited>
          <configuration>
            <jreleaser>
              <signing>
                <active>ALWAYS</active>
                <armored>true</armored>
              </signing>
              <deploy>
                <maven>
                  <nexus2>
                    <maven-central>
                      <active>ALWAYS</active>
                      <url>https://s01.oss.sonatype.org/service/local</url>
                      <snapshotUrl>https://s01.oss.sonatype.org/content/repositories/snapshots/</snapshotUrl>
                      <closeRepository>true</closeRepository>
                      <releaseRepository>true</releaseRepository>
                      <stagingRepositories>target/staging-deploy</stagingRepositories>
                    </maven-central>
                  </nexus2>
                </maven>
              </deploy>
            </jreleaser>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>

With script and CI job to publish snapshots:

https://github.com/cryostatio/cryostat-core/blob/5684f1faacad87ac637277b76f3efb71ee307ab2/.github/workflows/push-ci.yml#L38

https://github.com/cryostatio/cryostat-core/blob/main/.github/workflows/maven-central-publish.yml

https://github.com/cryostatio/cryostat-core/blob/main/release-snapshot.sh

and all environment variables exported as Actions secrets, etc.

Expected Behaviour

A snapshot release is successfully published.

Actual Behaviour

Publication fails:

https://github.com/cryostatio/cryostat-core/actions/runs/10800210575/job/29957690676

logs_28224562875.zip

Error:     [nexus2]  x cryostat-core-parent-4.0.0-20240910.203705-1.pom
[INFO] Writing output properties to target/jreleaser/output.properties
Error:  JReleaser failed after 50.813 s
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Cryostat Core Parent 4.0.0-SNAPSHOT:
[INFO] 
[INFO] Cryostat Core Parent ............................... FAILURE [ 56.526 s]
[INFO] libcryostat ........................................ SKIPPED
[INFO] Cryostat Core ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  57.471 s
[INFO] Finished at: 2024-09-10T20:38:25Z
[INFO] ------------------------------------------------------------------------
Error:  Failed to execute goal org.jreleaser:jreleaser-maven-plugin:1.14.0:deploy (default-cli) on project cryostat-core-parent: Execution default-cli of goal org.jreleaser:jreleaser-maven-plugin:1.14.0:deploy failed: Unexpected error: Unexpected error when deploying target/staging-deploy/io/cryostat/cryostat-core-parent/4.0.0-SNAPSHOT/cryostat-core-parent-4.0.0-20240910.203705-1.pom: Error when deploying artifact cryostat-core-parent-4.0.0-20240910.203705-1.pom: Got 400 reason: Bad Request, Malformed Path -> [Help 1]

Other logs from a similar project (actually a dependent of this one) run locally show a snippet like:

[INFO]      [nexus2]  - io/cryostat/cryostat-agent/0.5.0-SNAPSHOT/cryostat-agent-0.5.0-20240911.191738-1-javadoc.jar
[DEBUG]     [nexus2]  - deploying cryostat-agent-0.5.0-20240911.191738-1-javadoc.jar as /io/cryostat/cryostat-agent/0.5.0-SNAPSHOT/cryostat-agent-0.5.0-20240911.191738-1-javadoc.jar
[DEBUG]     [nexus2] url: https://s01.oss.sonatype.org/content/repositories/snapshots//io/cryostat/cryostat-agent/0.5.0-SNAPSHOT/cryostat-agent-0.5.0-20240911.191738-1-javadoc.jar

Here, the /snapshots//io/cryostat/ is noteworthy, with the // in the path. Visiting https://s01.oss.sonatype.org/content/repositories/snapshots//io/cryostat/cryostat-agent results in a Malformed Path error message, just like what JReleaser reports. Manually normalizing the path to https://s01.oss.sonatype.org/content/repositories/snapshots/io/cryostat/cryostat-agent/ results in the expected directory listing result.

Based on that finding, we removed the trailing slash from the JReleaser <snapshotUrl> configuration element:

cryostatio/cryostat-core#463

<snapshotUrl>https://s01.oss.sonatype.org/content/repositories/snapshots</snapshotUrl>

After this change our snapshot publication works again.

It seems like the URL paths should be normalized, in case the publication target server considers these empty path segments as invalid or otherwise unacceptable.

Or else, maybe the JReleaser documentation (ex. https://jreleaser.org/guide/latest/examples/maven/maven-central.html#_maven) and examples should be updated to remove the trailing slash from the snapshot URL?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions