Error on Github Packages for `-SNAPSHOT` maven artifacts with a classifier

If you upload a -SNAPSHOT version of maven artifacts with a classifier then you get an error when you try to read back the maven-metadata.xml

More details here:

HTTP/1.1 400 Bad Request
error retrieving metadata for snapshot file: lib-0.2-20200604.123456-4-sources.jar

for maven-metadata.xml

<metadata modelVersion="1.1.0">
  <groupId>com.example</groupId>
  <artifactId>lib</artifactId>
  <version>0.2-SNAPSHOT</version>
  <versioning>
    <snapshot>
      <timestamp>20200604.123456</timestamp>
      <buildNumber>4</buildNumber>
    </snapshot>
    <lastUpdated>20200604123456</lastUpdated>
    <snapshotVersions>
      <snapshotVersion>
        <classifier>sources</classifier>
        <extension>jar</extension>
        <value>0.2-20200604.123456-4</value>
        <updated>20200604123456</updated>
      </snapshotVersion>
      <snapshotVersion>
        <extension>jar</extension>
        <value>0.2-20200604.123456-4</value>
        <updated>20200604123456</updated>
      </snapshotVersion>
      <snapshotVersion>
        <extension>pom</extension>
        <value>0.2-20200604.123456-4</value>
        <updated>20200604123456</updated>
      </snapshotVersion>
      <snapshotVersion>
        <extension>module</extension>
        <value>0.2-20200604.123456-4</value>
        <updated>20200604123456</updated>
      </snapshotVersion>
    </snapshotVersions>
  </versioning>
</metadata>
2 Likes

I was wondering if there’s a public repository that uses a classifier what I could see?

mvn deploy has the same problem, so not specific to gradle, can’t deploy the same -SNAPSHOT twice with “sources” and “javadoc” jars.
You work around this with

mvn deploy -Dmaven.javadoc.skip=true -Dmaven.source.skip=true

for -SNAPSHOT versions.

1 Like

Hi @yogurtearl :wave:

Thanks for the extra details here. I knew about the issues with -sources.jar and -javadoc.jar files, but didn’t realize that they were called classifiers.

Do you know if there’s an issue with the maven-metadata.xml feed that GitHub Packages returns or does the problem happen when it tries to fetch the files?

Thanks,
Jamie.

I have a repository here that shows the issue with javadoc and sources classifiers:

If appears that retrieving the maven-metadata.xml fails completely when a package contains a classifier:

$ curl https://maven.pkg.github.com/jcansdale-test/gradle-java-publish/org/test/javadoc/gradle-java-publish/1.0-SNAPSHOT/maven-metadata.xml -v -u token:<READ_PACKAGES_PAT>

< HTTP/1.1 400 Bad Request
< Date: Wed, 10 Jun 2020 14:32:12 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 99
< Content-Security-Policy: default-src 'none';
< Server: GitHub Registry
< Strict-Transport-Security: max-age=31536000;
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
< X-Xss-Protection: 1; mode=block
< X-GitHub-Request-Id: FBF8:C5BE:1FD460:2B2CD6:5EE0EEEC
< 
error retrieving metadata for snapshot file: gradle-java-publish-1.0-20200528.110628-2-javadoc.jar

Hi guys!

I’ve got the same problem in our projects. The first maven deploy with a new SNAPSHOT version succeeds. The next run with the same SNAPSHOT version always fails with:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project myproject: Failed to retrieve remote metadata my-project:my-client:2.2.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata my-project:my-client:2.2.0-SNAPSHOT/maven-metadata.xml from/to my-repo (https://maven.pkg.github.com/my-company/my-repo): Transfer failed for https://maven.pkg.github.com/my-company/my-repo-maven/com/mycompany/my-client/2.2.0-SNAPSHOT/maven-metadata.xml 400 Bad Request

mvn deploy -Dmaven.javadoc.skip=true -Dmaven.source.skip=true
does not change this behavior. Do you have any idea for me?

1 Like

@yogurtearl, @scholz-sebastian,

I’m happy to say a fix for SNAPSHOT versions that have dependencies on a classifier was deployed last night. I hope this resolves the issues people were seeing. If you could confirm, that would be great!

Thanks,
Jamie.

the issue is still present:

  • if a maven SNAPSHOT artifact with additional files with classifiers are uploaded to github packages any attemp to download maven-metadata.xml file is failing with 400 HTTP resposne with “error retrieving metadata for snapshot file: artifact-id-2021.1-20210119.141410-1.jar” error. Files are visible in github packages also with the additional files with classifiers, but it’s not possible to download by maven (both from github actions or from local machine)
  • attempt to deploy SNAPSHOT artifact with additional files with classifier second time fails with 400 HTTP error (because downloading the maven-metadata.xml for the version is failing)
  • attempt to upload any artifact with a capital letter in artifactId is failing with 422 Unprocessable entity (regardless of presence of classifiers)

I can confirm this, we are running into the exact same issue.

additional observation is that for Maven SNAPSHOT artifacts github packages keeps many versions (maybe all?) of the SNAPSHOT artifact (files named like artifactId-0.4-20210112.140623-1.jar with the last number increased with each version)

@jcansdale, seems that this bug still exist ; I tried it today by sending SNAPSHOT artifact with a classifier and zip extension.

@jcansdale We are Enterprise customers trying to deploy a Quarkus “fat jar” build to a private Github Package, and that has a name like ‘test-service-2-SNAPSHOT-runner.jar’

As reported above, the first deployment is fine, but all subsequent deployments fail with 400 error as :

[WARNING] Could not transfer metadata com.xxxx.microservices:test-service:2-SNAPSHOT/maven-metadata.xml 
from/to github (https://maven.pkg.github.com/<myowner>/mic-test-service): transfer failed for
https://maven.pkg.github.com/<myowner>/mic-test-service/com/xxx/microservices/test-service/2-SNAPSHOT/maven-metadata.xml, 
status: 400 Bad Request

running with Maven debug -X set, every artifact to be updated fails with the following error message:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project 
test-service: Failed to retrieve remote metadata com.xxx.microservices:test-service:2-SNAPSHOT/maven-metadata.xml: 
Could not transfer metadata com.xxx.microservices:test-service:2-SNAPSHOT/maven-metadata.xml
 from/to github (https://maven.pkg.github.com/<myowner>/mic-test-service): transfer failed for
 https://maven.pkg.github.com/<myowner>/mic-test-service/com/xxx/microservices/test-service/2-SNAPSHOT/maven-metadata.xml, 
status: 400 Bad Request

This makes the Github Packages system unusable.