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

NullPointerException at com.sonatype.nexus.migration.repository.migrators.datastore.NpmRepositoryMigrator.recordMetadata

    XMLWordPrintable

    Details

      Description

      During migration from 2.14.13 to 3.33. Postgres, the following types of Exceptions were noticed in NXRM 3 nexus.log

      2021-08-25 17:55:58,954+0000 ERROR [plan-executor-14-thread-7]  admin com.sonatype.nexus.migration.repository.ProcessChangesStep - Failed processing of CREATE npmjs-internal:/examplepackage/-/examplepackage-230.0.87-test.1250.tgz, will ignore and move on. null
      java.lang.NullPointerException: null
      	at com.sonatype.nexus.migration.repository.migrators.datastore.NpmRepositoryMigrator.recordMetadata(NpmRepositoryMigrator.java:127)
      	at com.sonatype.nexus.migration.repository.migrators.RepositoryMigratorSupport.createOrUpdate(RepositoryMigratorSupport.java:151)
      	at com.sonatype.nexus.migration.repository.migrators.RepositoryMigratorSupport.processChange(RepositoryMigratorSupport.java:131)
      	at com.sonatype.nexus.migration.repository.RepositoryMigrator$processChange$1.call(Unknown Source)
      	at com.sonatype.nexus.migration.repository.ProcessChangesStep$_submit_closure2.doCall(ProcessChangesStep.groovy:336)
      	at com.sonatype.nexus.migration.repository.ProcessChangesStep$_submit_closure2.doCall(ProcessChangesStep.groovy)
      	at sun.reflect.GeneratedMethodAccessor731.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
      	at groovy.lang.Closure.call(Closure.java:420)
      	at groovy.lang.Closure.call(Closure.java:414)
      	at groovy.lang.Closure.run(Closure.java:501)
      	at org.sonatype.nexus.thread.internal.MDCAwareRunnable.run(MDCAwareRunnable.java:40)
      	at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120)
      	at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      

      In NX2 logs there is corresponding:

      2021-08-25 17:55:26,223+0000 WARN [qtp1218614546-546] *UNKNOWN com.sonatype.nexus.migrationagent.repository.migrators.NpmRepositoryMigrator - Path /examplepackage/-/examplepackage-230.0.87-test.1250.tgz in package examplepackage does not match a known version, skipping
      

      Reproduce

      1. Start with a test package.json in a local dir that includes this valid semantic version 1.0.87-test.1250+43260ff:
        {
          "name": "test-package",
          "version": "1.0.87-test.1250+43260ff",
          "description": "test-package description",
          "main": "index.js",
          "scripts": {
            "test": "echo \"Error: no test specified\" && exit 1"
          },
          "author": "Barney Rubble <b@example.com> (http://barnyrubble.example.com/)",
          "keywords": [
            "special",
            "sauce"
          ],
          "license": "ISC",
          "dependencies": {
            "date-fns": "^2.12.0",
            "grunt": "^1.0.0-rc1"
          }
        }
        
      1. Have an NXRM 2 instance running at with a hosted npm repo at https://localhost:8081/nexus/content/repositories/npmjs-internal - repo version 2.14.13 was used during this test.
      2. Configure NPM CLI with. suitable credentials
      3. npm publish --registry https://localhost:8081/nexus/content/repositories/npmjs-internal
      4. Verify the package metadata retrieved from https://localhost:8081/nexus/content/repositories/npmjs-internal/test-package only contains one version listed as 1.0.87-test.1250 ( not 1.0.87-test.1250+43260ff ) - this is expected and normal, this is exactly how the official registry behaves when deploying a package there with the same version.
      5. Verify the tarball URL in the package metadata refers to this URL http://localhost:8081/nexus/content/repositories/npmjs-internal/test-package/-/test-package-1230.0.87-test.1250.tgz and that downloading it works.
      6. Now stop NXRM, and move sonatype-work/nexus/db/npm directory aside.
      7. Start NXRM and manually run a rebuild hosted npm metadata task against the npmjs-internal repo.
      8. Now start migration to NXRM 3 (no matter Orient or NewDB) and get NullPointerException in NpmRepositoryMigrator

      Expected

      Diagnose the cause of the problem and prevent nullPointerException and if a non-resolvable problem, log a better message explaining what the problem is.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              orudyk Oleksii Rudyk
              Reporter:
              plynch Peter Lynch
              Last Updated By:
              Maksym Kalachov Maksym Kalachov
              Team:
              NXRM - Rocket Raccoon
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  tigCommentSecurity.panel-title