Details
Description
Reproduce
Create this type of NPM format repository structure:
npm (group) | |-- npm-hosted (group) | | | |-- npm-releases (hosted) | | | `-- npm-snapshots (hosted) | `-- npm-proxy-npmjs (proxy, official registry)
Then follow these instructions:
- create a scoped package @test/some-package with version 1.0.0-rc.1
- publish this package to the npm-releases repository with
npm publish
- in a different directory create the same scoped package with a different version 1.0.0-rc.1-20200601210614
- publish this package to the npm-snapshots repository with
npm publish
- in another directory try to list the dist tags for @test/some-package when logged into the npm group repository:
npm dist-tag ls @test/some-package npm ERR! dist-tag ls Couldn't get dist-tag data for Result { npm ERR! dist-tag ls type: 'tag', npm ERR! dist-tag ls registry: true, npm ERR! dist-tag ls where: undefined, npm ERR! dist-tag ls raw: '@test/some-package', npm ERR! dist-tag ls name: '@test/some-package', npm ERR! dist-tag ls escapedName: '@test%2fsome-package', npm ERR! dist-tag ls scope: '@test', npm ERR! dist-tag ls rawSpec: '', npm ERR! dist-tag ls saveSpec: null, npm ERR! dist-tag ls fetchSpec: 'latest', npm ERR! dist-tag ls gitRange: undefined, npm ERR! dist-tag ls gitCommittish: undefined, npm ERR! dist-tag ls hosted: undefined npm ERR! dist-tag ls } npm ERR! code E500 npm ERR! 500 javax.servlet.ServletException: java.lang.ClassCastException: org.sonatype.nexus.repository.view.payloads.BytesPayload cannot be cast to org.sonatype.nexus.repository.view.Content - GET http://127.0.0.1:8081/repository/npm/-/package/@test%2fsome-package/dist-tags
The stack trace of the exception being thrown is:
3.22.0 example stack trace for 500 response
java.lang.ClassCastException: org.sonatype.nexus.repository.view.payloads.BytesPayload cannot be cast to org.sonatype.nexus.repository.view.Content at org.sonatype.nexus.repository.npm.internal.NpmFacetUtils.lambda$7(NpmFacetUtils.java:566) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) at org.sonatype.nexus.repository.npm.internal.NpmFacetUtils.mergeDistTagResponse(NpmFacetUtils.java:570) at org.sonatype.nexus.repository.npm.internal.NpmFacetUtils$mergeDistTagResponse.call(Unknown Source) at org.sonatype.nexus.repository.npm.internal.NpmGroupDistTagsHandler.doGet(NpmGroupDistTagsHandler.groovy:55) at org.sonatype.nexus.repository.group.GroupHandler.handle(GroupHandler.java:95)
Expected
- npm dist-tags command should not get 500 response
- npm install commands which rely on dist-tags being non-empty to resolve packages should not fail to resolve the expected versions
- avoid ClassCastException