Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-29095

Truncated MavenProxyFacet URL generation causing 404 for maven metadata

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: New
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.32.0, 3.34.0
    • Fix Version/s: None
    • Component/s: Maven
    • Labels:
    • Story Points:
      2
    • Notability:
      2

      Description

      When nested maven group repo is created with a hosted and a proxy member repo then fetching the maven metadata will cause truncated MavenProxyFacet URL generation.

       Steps to reproduce the issue.

      Step-1). Create a Maven Hosted repo.

      cat > /tmp/maven-hosted-1.json << 'EOF'
      {
        "name": "maven-hosted-1",
        "online": true,
        "storage": {
          "blobStoreName": "default",
          "strictContentTypeValidation": true,
          "writePolicy": "ALLOW"
        },
        "cleanup": {
          "policyNames": [
          ]
        },
        "component": {
          "proprietaryComponents": true
        },
        "maven": {
          "versionPolicy": "MIXED",
          "layoutPolicy": "STRICT",
          "contentDisposition": "ATTACHMENT"
        }
      }
      EOF
      
      
      
      curl -u admin:admin123 -H 'Content-Type: application/json' -X 'POST'  -d@/tmp/maven-hosted-1.json  http://localhost:8081/service/rest/v1/repositories/maven/hosted
      

      Step-2). Create a Group repo "maven-group-A" with "maven-hosted-1" repo as a member.

      cat > /tmp/maven-group-A.json << 'EOF'
      {
        "name": "maven-group-A",
        "online": true,
        "storage": {
          "blobStoreName": "default",
          "strictContentTypeValidation": true
        },
        "group": {
          "memberNames": [
            "maven-hosted-1"
          ]
        }
      }
      EOF
      
      
      curl -u admin:admin123 -H 'Content-Type: application/json' -X 'POST' -d@/tmp/maven-group-A.json  http://localhost:8081/service/rest/v1/repositories/maven/group
      

      Step-3). Create a Group repo "maven-group-B" with two member repos. Notice the first member repo should be hosted one "maven-group-A" and second member as "maven-central".

      cat > /tmp/maven-group-B.json << 'EOF'
      {
        "name": "maven-group-B",
        "online": true,
        "storage": {
          "blobStoreName": "default",
          "strictContentTypeValidation": true
        },
        "group": {
          "memberNames": [
            "maven-group-A",
            "maven-central"
          ]
        }
      }
      EOF
      
      
      curl -u admin:admin123 -H 'Content-Type: application/json' -X 'POST' -d@/tmp/maven-group-B.json  http://localhost:8081/service/rest/v1/repositories/maven/group
      

      Step-4). Deploy a Simple Component to "maven-hosted-1"

      REPO_NAME="maven-hosted-1"
      GROUP_ID="org.example"
      ARTIFACT_ID="Test"
      VERSION="1.0.0"
      
      echo hello > test.txt
      jar -cvf "${ARTIFACT_ID}-${VERSION}.jar" test.txt
      
      curl -v -u admin:admin123 -X POST "http://localhost:8081/service/rest/v1/components?repository=${REPO_NAME}" -F maven2.groupId="${GROUP_ID}" -F maven2.artifactId=${ARTIFACT_ID} -F maven2.version=${VERSION} -F maven2.asset1=@`pwd`/${ARTIFACT_ID}-${VERSION}.jar -F maven2.asset1.extension=jar  -F maven2.generate-pom=true
      

      Step-5). Enable DEBUG logging for the following logger "org.apache.http" and invalidate cache for the "maven-group-B" .

      curl -v -u admin:admin123 -H "Content-Type: application/json" -X PUT -d '{ "name": "org.apache.http", "level": "DEBUG",  "override": true }' "http://localhost:8081/service/rest/internal/ui/loggingConfiguration/org.apache.http"
      

      Step-6). Try to fetch the Maven metadata "maven-metadata.xml.sha1" file from the nested Maven group repo "maven-group-B".

      curl -u admin:admin123 http://localhost:8081/repository/maven-group-B/org/example/Test/maven-metadata.xml.sha1
      

      Notice the nexus.log shows that the truncated MavenProxyFacet URL generated which causes 404 results.

      2021-09-27 14:07:43,072+1000 INFO  [qtp1268171709-606]  admin org.sonatype.nexus.repository.maven.internal.orient.OrientMavenGroupFacet - Invalidating group caches of maven-group-B
      2021-09-27 14:07:43,072+1000 INFO  [qtp1268171709-606]  admin org.sonatype.nexus.repository.maven.internal.orient.OrientMavenGroupFacet - Invalidating group caches of maven-group-A
      2021-09-27 14:07:43,073+1000 INFO  [qtp1268171709-606]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenProxyFacet - Invalidating proxy caches of maven-central
      2021-09-27 14:08:46,599+1000 WARN  [elasticsearch[33252E5D-1A149F9A-8A7C100F-CD642D6B-07A03668][management][T#3]]  *SYSTEM org.elasticsearch.cluster.routing.allocation.decider - [33252E5D-1A149F9A-8A7C100F-CD642D6B-07A03668] high disk watermark [90%] exceeded on [gVqO4GJMRP-M0qUwli5RiQ][33252E5D-1A149F9A-8A7C100F-CD642D6B-07A03668][/opt/nexus/nexus-3.34.0-01/sonatype-work/nexus3/elasticsearch/nexus/nodes/0] free: 5.6gb[8.3%], shards will be relocated away from this node
      2021-09-27 14:08:46,599+1000 INFO  [elasticsearch[33252E5D-1A149F9A-8A7C100F-CD642D6B-07A03668][management][T#3]]  *SYSTEM org.elasticsearch.cluster.routing.allocation.decider - [33252E5D-1A149F9A-8A7C100F-CD642D6B-07A03668] rerouting shards: [high disk watermark exceeded on one or more nodes]
      2021-09-27 14:08:48,549+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenFacetImpl - GET maven-group-A : org/example/Test/maven-metadata.xml
      2021-09-27 14:08:48,551+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenFacetImpl - GET maven-hosted-1 : org/example/Test/maven-metadata.xml
      2021-09-27 14:08:48,553+1000 DEBUG [streamcopier-24-thread-24]  admin org.sonatype.nexus.repository.maven.internal.group.RepositoryMetadataMerger - Merge metadata for org/example/Test/maven-metadata.xml
      2021-09-27 14:08:48,556+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenFacetImpl - PUT maven-group-A : org/example/Test/maven-metadata.xml.sha1
      2021-09-27 14:08:48,559+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenFacetImpl - PUT maven-group-A : org/example/Test/maven-metadata.xml.sha256
      2021-09-27 14:08:48,563+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenFacetImpl - PUT maven-group-A : org/example/Test/maven-metadata.xml.sha512
      2021-09-27 14:08:48,567+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenFacetImpl - PUT maven-group-A : org/example/Test/maven-metadata.xml.md5
      2021-09-27 14:08:48,575+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenFacetImpl - GET maven-central : org/example/Test/maven-metadata.xml
      2021-09-27 14:08:48,576+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenProxyFacet - Fetching: GET https://repo1.maven.org/maven2/rg/example/Test/maven-metadata.xml HTTP/1.1
      2021-09-27 14:08:48,576+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: ignoreCookies
      2021-09-27 14:08:48,576+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
      2021-09-27 14:08:48,577+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://repo1.maven.org:443
      2021-09-27 14:08:48,642+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to repo1.maven.org/151.101.52.209:443
      2021-09-27 14:08:48,642+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to repo1.maven.org/151.101.52.209:443 with timeout 20000
      2021-09-27 14:08:48,803+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1.2]
      2021-09-27 14:08:48,804+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
      2021-09-27 14:08:48,805+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory - Starting handshake
      2021-09-27 14:08:48,969+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory - Secure session established
      2021-09-27 14:08:48,970+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory -  negotiated protocol: TLSv1.2
      2021-09-27 14:08:48,970+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory -  negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
      2021-09-27 14:08:48,970+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory -  peer principal: CN=repo1.maven.org
      2021-09-27 14:08:48,971+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory -  peer alternative names: [repo1.maven.org]
      2021-09-27 14:08:48,971+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.conn.ssl.SSLConnectionSocketFactory -  issuer principal: CN=GlobalSign Atlas R3 DV TLS CA H2 2021, O=GlobalSign nv-sa, C=BE
      2021-09-27 14:08:48,971+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 10.0.2.15:56646<->151.101.52.209:443
      2021-09-27 14:08:48,972+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-85: set socket timeout to 20000
      2021-09-27 14:08:48,972+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.impl.execchain.MainClientExec - Executing request GET /maven2/rg/example/Test/maven-metadata.xml HTTP/1.1
      2021-09-27 14:08:48,972+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
      2021-09-27 14:08:48,972+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
      2021-09-27 14:08:48,973+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 >> GET /maven2/rg/example/Test/maven-metadata.xml HTTP/1.1
      2021-09-27 14:08:48,973+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 >> Host: repo1.maven.org
      2021-09-27 14:08:48,973+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 >> Connection: Keep-Alive
      2021-09-27 14:08:48,974+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 >> User-Agent: Nexus/3.34.0-01 (PRO; Linux; 5.11.0-36-generic; amd64; 1.8.0_292)
      2021-09-27 14:08:48,974+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 >> Accept-Encoding: gzip,deflate
      2021-09-27 14:08:49,136+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << HTTP/1.1 404 Not Found
      2021-09-27 14:08:49,137+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << Connection: keep-alive
      2021-09-27 14:08:49,137+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << Content-Length: 554
      2021-09-27 14:08:49,137+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << Last-Modified: Wed, 10 Aug 2016 15:08:35 GMT
      2021-09-27 14:08:49,138+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << ETag: "1fb066da6a67c7c02962f59b4b8cd1ee"
      2021-09-27 14:08:49,138+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << x-amz-error-code: NoSuchKey
      2021-09-27 14:08:49,138+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << x-amz-error-message: The specified key does not exist.
      2021-09-27 14:08:49,138+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << x-amz-error-detail-Key: maven2/rg/example/Test/maven-metadata.xml
      2021-09-27 14:08:49,139+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << Content-Type: text/html
      2021-09-27 14:08:49,139+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << Via: 1.1 varnish, 1.1 varnish
      2021-09-27 14:08:49,139+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << Accept-Ranges: bytes
      2021-09-27 14:08:49,140+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << Date: Mon, 27 Sep 2021 04:08:49 GMT
      2021-09-27 14:08:49,140+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << Age: 2304
      2021-09-27 14:08:49,140+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << X-Served-By: cache-bwi5120-BWI, cache-sea4423-SEA
      2021-09-27 14:08:49,140+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << X-Cache: MISS, HIT
      2021-09-27 14:08:49,140+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << X-Cache-Hits: 0, 1
      2021-09-27 14:08:49,141+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.headers - http-outgoing-85 << X-Timer: S1632715729.054908,VS0,VE1
      2021-09-27 14:08:49,141+1000 DEBUG [qtp1268171709-625]  admin org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive for 30000 MILLISECONDS
      2021-09-27 14:08:49,141+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenProxyFacet - Response: HttpResponseProxy{HTTP/1.1 404 Not Found [Connection: keep-alive, Content-Length: 554, Last-Modified: Wed, 10 Aug 2016 15:08:35 GMT, ETag: "1fb066da6a67c7c02962f59b4b8cd1ee", x-amz-error-code: NoSuchKey, x-amz-error-message: The specified key does not exist., x-amz-error-detail-Key: maven2/rg/example/Test/maven-metadata.xml, Content-Type: text/html, Via: 1.1 varnish, 1.1 varnish, Accept-Ranges: bytes, Date: Mon, 27 Sep 2021 04:08:49 GMT, Age: 2304, X-Served-By: cache-bwi5120-BWI, cache-sea4423-SEA, X-Cache: MISS, HIT, X-Cache-Hits: 0, 1, X-Timer: S1632715729.054908,VS0,VE1] ResponseEntityProxy{[Content-Type: text/html,Content-Length: 554,Chunked: false]}}
      2021-09-27 14:08:49,141+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenProxyFacet - Status: HTTP/1.1 404 Not Found
      

      NOTICE: group Name is truncated from "org/example/Test" to "rg/example/Test"

      2021-09-27 14:08:48,576+1000 DEBUG [qtp1268171709-625]  admin org.sonatype.nexus.repository.maven.internal.orient.MavenProxyFacet - Fetching: GET https://repo1.maven.org/maven2/rg/example/Test/maven-metadata.xml HTTP/1.1
      

      Current Behaviour:

      • URL is not getting generated correctly. As we see "org" is truncated to "rg"

      Expected Behaviour:

      • URL should have been generated correctly.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jsensharma Jay Kumar SenSharma
            Last Updated By:
            Grace Lee Grace Lee
            Team:
            NXRM - Mad Max
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Date of First Response:

                tigCommentSecurity.panel-title