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

npm package.json author field not properly handled when a string instead of Map

    XMLWordPrintable

    Details

    • Story Points:
      3
    • Sprint:
      NXRM Rocket Sprint 15, NXRM Rocket Sprint 16
    • Notability:
      2

      Description

      A customer was performing an upgrade from NXRM 2.14.13 to NXRM 3.33.1 (Postgres).

      Many NPM packages were failing to migrate wth ERROR messages like this in NXRM 3 nexus.log:

      2021-08-23 15:46:25,486+0000 ERROR [plan-executor-14-thread-7]  admin com.sonatype.nexus.migration.repository.ProcessChangesStep - Failed processing of CREATE npmjs-internal:/example-package/-/example-package-1.0.1.tgz, will ignore and move on. child 'author' not a Map
      java.lang.IllegalStateException: child 'author' not a Map
       at com.google.common.base.Preconditions.checkState(Preconditions.java:591)
       at org.sonatype.nexus.common.collect.NestedAttributesMap.child(NestedAttributesMap.java:128)
       at com.sonatype.nexus.migration.repository.migrators.datastore.NpmRepositoryMigrator.extractFormatAttributes(NpmRepositoryMigrator.java:181)
       at com.sonatype.nexus.migration.repository.migrators.datastore.NpmRepositoryMigrator.recordMetadata(NpmRepositoryMigrator.java:141)
       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$3.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.GeneratedMethodAccessor518.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)
      

      According to https://docs.npmjs.com/cli/v7/configuring-npm/package-json#people-fields-author-contributors

      The "author" is one person. "contributors" is an array of people. A "person" is an object with a "name" field and optionally "url" and "email", like this:

      {
       "name" : "Barney Rubble",
       "email" : "b@rubble.com",
       "url" : "http://barnyrubble.tumblr.com/"
      }
      

      Or you can shorten that all into a single string, and npm will parse it for you:

      {
       "author": "Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)"
      }
      

      Both email and url are optional either way.

      npm also sets a top-level "maintainers" field with your npm user info.

      So it can be a Map or a single string. NXRM 3 new "datastore" implementation is only expecting and handling a Map. In contrast the OrientDB legacy code has facility to handle both a Map and a string value.

      Expected

      Handle accepting both a Map and a String value for the author field in package.json, thereby successfully migrating this type of package from NXRM 2.

      Add missing datastore tests when author is a string.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mkalachov Maksym Kalachov
              Reporter:
              plynch Peter Lynch
              Last Updated By:
              Michael Prescott Michael Prescott
              Team:
              NXRM - Rocket Raccoon
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  tigCommentSecurity.panel-title