[RTFACT-14171] NPM 500 ERROR when External Dependency Rewrite enabled Created: 01/May/17  Updated: 26/Dec/17  Resolved: 26/Dec/17

Status: Resolved
Project: Artifactory Binary Repository
Component/s: NPM
Affects Version/s: 4.16.0, 5.2.0, 5.2.1
Fix Version/s: 5.8.0

Type: Bug Priority: Normal
Reporter: Ariel Kabov Assignee: Inbar Tal (Inactive)
Resolution: Fixed Votes: 1
Labels: None


 Description   

In Artifactory, when External Dependency Rewrite is enabled for a virtual NPM repository, some packages can not be resolved. For example, the package "equals".

Verbosed output for the "npm install equals -ddd" command:

npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'install',
npm verb cli   'equals',
npm verb cli   '-ddd' ]
npm info using npm@4.2.0
npm info using node@v6.10.0
npm verb config Skipping project config: /Users/arielk/.npmrc. (matches userconfig)
npm sill loadCurrentTree Starting
npm sill install loadCurrentTree
npm sill install readLocalPackageData
npm sill fetchPackageMetaData equals
npm sill fetchNamedPackageData equals
npm sill mapToRegistry name equals
npm sill mapToRegistry using default registry
npm sill mapToRegistry registry http://artifactory:8081/artifactory/api/npm/npm
npm sill mapToRegistry data Result {
npm sill mapToRegistry   raw: 'equals',
npm sill mapToRegistry   scope: null,
npm sill mapToRegistry   escapedName: 'equals',
npm sill mapToRegistry   name: 'equals',
npm sill mapToRegistry   rawSpec: '',
npm sill mapToRegistry   spec: 'latest',
npm sill mapToRegistry   type: 'tag' }
npm sill mapToRegistry uri http://artifactory:8081/artifactory/api/npm/npm/equals
npm verb request uri http://mill.jfrog.info:12015/artifactory/api/npm/npm/equals
npm verb request always-auth set; sending authorization
npm info attempt registry request try #1 at 11:15:29 AM
npm verb request id f34b70234e70f19b
npm http request GET http://artifactory:8081/artifactory/api/npm/npm/equals
npm http 500 http://artifactory:8081/artifactory/api/npm/npm/equals
npm verb headers { server: 'Artifactory/5.2.0',
npm verb headers   'x-artifactory-id': '8fbc6fbc4f6bb8b7:-1e437d36:15bae5d9d27:-8000',
npm verb headers   'content-type': 'application/json',
npm verb headers   'transfer-encoding': 'chunked',
npm verb headers   date: 'Mon, 01 May 2017 08:15:30 GMT',
npm verb headers   connection: 'close' }
npm info retry will retry, error on last attempt: Error: Registry returned 500 for GET on http://artifactory:8081/artifactory/api/npm/npm/equals
npm info attempt registry request try #2 at 11:15:40 AM
npm http request GET http://artifactory:8081/artifactory/api/npm/npm/equals
npm http 500 http://artifactory:8081/artifactory/api/npm/npm/equals
npm verb headers { server: 'Artifactory/5.2.0',
npm verb headers   'x-artifactory-id': '8fbc6fbc4f6bb8b7:-1e437d36:15bae5d9d27:-8000',
npm verb headers   'content-type': 'application/json',
npm verb headers   'transfer-encoding': 'chunked',
npm verb headers   date: 'Mon, 01 May 2017 08:15:41 GMT',
npm verb headers   connection: 'close' }
npm info retry will retry, error on last attempt: Error: Registry returned 500 for GET on http://artifactory:8081/artifactory/api/npm/npm/equals
npm info attempt registry request try #3 at 11:16:40 AM
npm http request GET http://artifactory:8081/artifactory/api/npm/npm/equals
npm http 500 http://artifactory:8081/artifactory/api/npm/npm/equals
npm verb headers { server: 'Artifactory/5.2.0',
npm verb headers   'x-artifactory-id': '8fbc6fbc4f6bb8b7:-1e437d36:15bae5d9d27:-8000',
npm verb headers   'content-type': 'application/json',
npm verb headers   'transfer-encoding': 'chunked',
npm verb headers   date: 'Mon, 01 May 2017 08:16:42 GMT',
npm verb headers   connection: 'close' }
npm sill get cb [ 500,
npm sill get   { server: 'Artifactory/5.2.0',
npm sill get     'x-artifactory-id': '8fbc6fbc4f6bb8b7:-1e437d36:15bae5d9d27:-8000',
npm sill get     'content-type': 'application/json',
npm sill get     'transfer-encoding': 'chunked',
npm sill get     date: 'Mon, 01 May 2017 08:16:42 GMT',
npm sill get     connection: 'close' } ]
npm sill fetchPackageMetaData Error: Registry returned 500 for GET on http://artifactory:8081/artifactory/api/npm/npm/equals
npm sill fetchPackageMetaData     at makeError (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:304:12)
npm sill fetchPackageMetaData     at CachingRegistryClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:282:14)
npm sill fetchPackageMetaData     at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:212:14)
npm sill fetchPackageMetaData     at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:186:22)
npm sill fetchPackageMetaData     at emitTwo (events.js:106:13)
npm sill fetchPackageMetaData     at Request.emit (events.js:191:7)
npm sill fetchPackageMetaData     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1081:10)
npm sill fetchPackageMetaData     at emitOne (events.js:96:13)
npm sill fetchPackageMetaData     at Request.emit (events.js:188:7)
npm sill fetchPackageMetaData     at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1001:12)
npm sill fetchPackageMetaData  error for equals { Error: Registry returned 500 for GET on http://mill.jfrog.info:12015/artifactory/api/npm/npm/equals
npm sill fetchPackageMetaData     at makeError (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:304:12)
npm sill fetchPackageMetaData     at CachingRegistryClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:282:14)
npm sill fetchPackageMetaData     at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:212:14)
npm sill fetchPackageMetaData     at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:186:22)
npm sill fetchPackageMetaData     at emitTwo (events.js:106:13)
npm sill fetchPackageMetaData     at Request.emit (events.js:191:7)
npm sill fetchPackageMetaData     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1081:10)
npm sill fetchPackageMetaData     at emitOne (events.js:96:13)
npm sill fetchPackageMetaData     at Request.emit (events.js:188:7)
npm sill fetchPackageMetaData     at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1001:12) pkgid: 'artifactory', statusCode: 500, code: 'E500' }
npm sill rollbackFailedOptional Starting
npm sill rollbackFailedOptional Finishing
npm sill runTopLevelLifecycles Finishing
npm sill install printInstalled
npm verb stack Error: Registry returned 500 for GET on http://mill.jfrog.info:12015/artifactory/api/npm/npm/equals
npm verb stack     at makeError (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:304:12)
npm verb stack     at CachingRegistryClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:282:14)
npm verb stack     at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:212:14)
npm verb stack     at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:186:22)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at Request.emit (events.js:191:7)
npm verb stack     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1081:10)
npm verb stack     at emitOne (events.js:96:13)
npm verb stack     at Request.emit (events.js:188:7)
npm verb stack     at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1001:12)
npm verb statusCode 500
npm verb pkgid artifactory
npm verb cwd /Users/arielk
npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "equals" "-ddd"
npm ERR! node v6.10.0
npm ERR! npm  v4.2.0
npm ERR! code E500

npm ERR! Registry returned 500 for GET on http://artifactory:8081/artifactory/api/npm/npm/equals
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm verb exit [ 1, true ]

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/arielk/.npm/_logs/2017-05-01T08_16_41_226Z-debug.log

From Artifactory.log:

2017-05-01 08:15:30,969 [http-nio-8081-exec-2] [ERROR] (o.j.r.n.NpmMetadataExtractor:120) - Unable to find or parse correctly the package archive ('package.json') within the tarball content: Input is not in the .gz format
java.io.IOException: Input is not in the .gz format
	at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.init(GzipCompressorInputStream.java:162) ~[commons-compress-1.10.jar:1.10]
	at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.<init>(GzipCompressorInputStream.java:135) ~[commons-compress-1.10.jar:1.10]
	at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.<init>(GzipCompressorInputStream.java:100) ~[commons-compress-1.10.jar:1.10]
	at org.jfrog.repomd.npm.NpmMetadataExtractor.read(NpmMetadataExtractor.java:95) [npm-4.3.25.jar:na]
	at org.jfrog.repomd.npm.NpmMetadataExtractor.extractAsSystem(NpmMetadataExtractor.java:54) [npm-4.3.25.jar:na]
	at org.jfrog.repomd.npm.NpmMetadataExtractor.extract(NpmMetadataExtractor.java:41) [npm-4.3.25.jar:na]
	at org.artifactory.addon.npm.NpmServiceImpl.getNpmMetadata(NpmServiceImpl.java:78) [artifactory-addon-npm-5.2.0.jar:na]
	at sun.reflect.GeneratedMethodAccessor605.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
	at com.sun.proxy.$Proxy114.getNpmMetadata(Unknown Source) [na:na]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.lambda$1(NpmPackageMetadataMerger.java:148) [artifactory-addon-npm-5.2.0.jar:na]
	at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:671) ~[na:1.8.0_102]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.lambda$0(NpmPackageMetadataMerger.java:138) [artifactory-addon-npm-5.2.0.jar:na]
	at java.util.HashMap$Values.forEach(HashMap.java:980) ~[na:1.8.0_102]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.fetchAndReplaceExternalDependencies(NpmPackageMetadataMerger.java:136) [artifactory-addon-npm-5.2.0.jar:na]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.mergeNpmPackageMetadata(NpmPackageMetadataMerger.java:108) [artifactory-addon-npm-5.2.0.jar:na]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.merge(NpmPackageMetadataMerger.java:98) [artifactory-addon-npm-5.2.0.jar:na]
	at org.artifactory.addon.npm.repo.merge.NpmMetadataMerger.getMergedResult(NpmMetadataMerger.java:65) ~[artifactory-addon-npm-5.2.0.jar:na]
	at org.artifactory.addon.npm.repo.NpmVirtualRepoHandler.getPackageMetadata(NpmVirtualRepoHandler.java:72) ~[artifactory-addon-npm-5.2.0.jar:na]
	at org.jfrog.repomd.npm.rest.NpmSubResource.packageInfo(NpmSubResource.java:46) ~[npm-4.3.25.jar:na]
	at sun.reflect.GeneratedMethodAccessor593.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:137) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) ~[jersey-servlet-1.19.jar:1.19]
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) ~[jersey-servlet-1.19.jar:1.19]
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) ~[jersey-servlet-1.19.jar:1.19]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[servlet-api.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[catalina.jar:8.0.41]
	at org.artifactory.webapp.servlet.RepoFilter.execute(RepoFilter.java:185) ~[artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.RepoFilter.doFilter(RepoFilter.java:94) ~[artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[catalina.jar:8.0.41]
	at org.artifactory.webapp.servlet.authentication.ArtifactoryAuthenticationFilterChain.lambda$1(ArtifactoryAuthenticationFilterChain.java:136) ~[artifactory-web-application-5.2.0.jar:na]
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:201) ~[spring-security-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
	at org.artifactory.webapp.servlet.authentication.ArtifactoryBasicAuthenticationFilter.doFilter(ArtifactoryBasicAuthenticationFilter.java:84) ~[artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.authentication.ArtifactoryAuthenticationFilterChain.doFilter(ArtifactoryAuthenticationFilterChain.java:172) ~[artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.AccessFilter.authenticateAndExecute(AccessFilter.java:281) ~[artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.AccessFilter.doFilterInternal(AccessFilter.java:205) ~[artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.AccessFilter.doFilter(AccessFilter.java:165) ~[artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[catalina.jar:8.0.41]
	at org.artifactory.webapp.servlet.RequestFilter.doFilter(RequestFilter.java:67) ~[artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[catalina.jar:8.0.41]
	at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:164) ~[spring-session-1.2.2.RELEASE.jar:na]
	at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80) ~[spring-session-1.2.2.RELEASE.jar:na]
	at org.artifactory.webapp.servlet.SessionFilter.doFilter(SessionFilter.java:62) ~[artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[catalina.jar:8.0.41]
	at org.artifactory.webapp.servlet.ArtifactoryFilter.doFilter(ArtifactoryFilter.java:116) ~[artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) ~[catalina.jar:8.0.41]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) ~[catalina.jar:8.0.41]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:509) ~[catalina.jar:8.0.41]
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1104) ~[tomcat-coyote.jar:8.0.41]
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684) ~[tomcat-coyote.jar:8.0.41]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1524) ~[tomcat-coyote.jar:8.0.41]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1480) ~[tomcat-coyote.jar:8.0.41]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_102]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_102]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:8.0.41]
	at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_102]
2017-05-01 08:15:30,973 [http-nio-8081-exec-2] [ERROR] (o.a.r.c.e.GlobalExceptionMapper:48) - java.io.IOException: Input is not in the .gz format
java.lang.RuntimeException: java.io.IOException: Input is not in the .gz format
	at org.jfrog.repomd.npm.NpmMetadataExtractor.read(NpmMetadataExtractor.java:122) ~[npm-4.3.25.jar:na]
	at org.jfrog.repomd.npm.NpmMetadataExtractor.extractAsSystem(NpmMetadataExtractor.java:54) ~[npm-4.3.25.jar:na]
	at org.jfrog.repomd.npm.NpmMetadataExtractor.extract(NpmMetadataExtractor.java:41) ~[npm-4.3.25.jar:na]
	at org.artifactory.addon.npm.NpmServiceImpl.getNpmMetadata(NpmServiceImpl.java:78) ~[artifactory-addon-npm-5.2.0.jar:na]
	at sun.reflect.GeneratedMethodAccessor605.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) ~[spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
	at com.sun.proxy.$Proxy114.getNpmMetadata(Unknown Source) ~[na:na]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.lambda$1(NpmPackageMetadataMerger.java:148) ~[artifactory-addon-npm-5.2.0.jar:na]
	at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:671) ~[na:1.8.0_102]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.lambda$0(NpmPackageMetadataMerger.java:138) ~[artifactory-addon-npm-5.2.0.jar:na]
	at java.util.HashMap$Values.forEach(HashMap.java:980) ~[na:1.8.0_102]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.fetchAndReplaceExternalDependencies(NpmPackageMetadataMerger.java:136) ~[artifactory-addon-npm-5.2.0.jar:na]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.mergeNpmPackageMetadata(NpmPackageMetadataMerger.java:108) ~[artifactory-addon-npm-5.2.0.jar:na]
	at org.artifactory.addon.npm.repo.merge.NpmPackageMetadataMerger.merge(NpmPackageMetadataMerger.java:98) ~[artifactory-addon-npm-5.2.0.jar:na]
	at org.artifactory.addon.npm.repo.merge.NpmMetadataMerger.getMergedResult(NpmMetadataMerger.java:65) ~[artifactory-addon-npm-5.2.0.jar:na]
	at org.artifactory.addon.npm.repo.NpmVirtualRepoHandler.getPackageMetadata(NpmVirtualRepoHandler.java:72) ~[artifactory-addon-npm-5.2.0.jar:na]
	at org.jfrog.repomd.npm.rest.NpmSubResource.packageInfo(NpmSubResource.java:46) ~[npm-4.3.25.jar:na]
	at sun.reflect.GeneratedMethodAccessor593.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:137) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) ~[jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) [jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) [jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) [jersey-server-1.19.jar:1.19]
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) [jersey-server-1.19.jar:1.19]
	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) [jersey-servlet-1.19.jar:1.19]
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) [jersey-servlet-1.19.jar:1.19]
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) [jersey-servlet-1.19.jar:1.19]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [servlet-api.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) [catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.41]
	at org.artifactory.webapp.servlet.RepoFilter.execute(RepoFilter.java:185) [artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.RepoFilter.doFilter(RepoFilter.java:94) [artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.41]
	at org.artifactory.webapp.servlet.authentication.ArtifactoryAuthenticationFilterChain.lambda$1(ArtifactoryAuthenticationFilterChain.java:136) [artifactory-web-application-5.2.0.jar:na]
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:201) ~[spring-security-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
	at org.artifactory.webapp.servlet.authentication.ArtifactoryBasicAuthenticationFilter.doFilter(ArtifactoryBasicAuthenticationFilter.java:84) ~[artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.authentication.ArtifactoryAuthenticationFilterChain.doFilter(ArtifactoryAuthenticationFilterChain.java:172) [artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.AccessFilter.authenticateAndExecute(AccessFilter.java:281) ~[artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.AccessFilter.doFilterInternal(AccessFilter.java:205) ~[artifactory-web-application-5.2.0.jar:na]
	at org.artifactory.webapp.servlet.AccessFilter.doFilter(AccessFilter.java:165) ~[artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.41]
	at org.artifactory.webapp.servlet.RequestFilter.doFilter(RequestFilter.java:67) ~[artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.41]
	at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:164) ~[spring-session-1.2.2.RELEASE.jar:na]
	at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80) ~[spring-session-1.2.2.RELEASE.jar:na]
	at org.artifactory.webapp.servlet.SessionFilter.doFilter(SessionFilter.java:62) ~[artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.41]
	at org.artifactory.webapp.servlet.ArtifactoryFilter.doFilter(ArtifactoryFilter.java:116) ~[artifactory-web-application-5.2.0.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.41]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.41]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) ~[catalina.jar:8.0.41]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) ~[catalina.jar:8.0.41]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) ~[catalina.jar:8.0.41]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:509) ~[catalina.jar:8.0.41]
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1104) ~[tomcat-coyote.jar:8.0.41]
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684) ~[tomcat-coyote.jar:8.0.41]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1524) ~[tomcat-coyote.jar:8.0.41]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1480) ~[tomcat-coyote.jar:8.0.41]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_102]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_102]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:8.0.41]
	at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_102]
Caused by: java.io.IOException: Input is not in the .gz format
	at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.init(GzipCompressorInputStream.java:162) ~[commons-compress-1.10.jar:1.10]
	at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.<init>(GzipCompressorInputStream.java:135) ~[commons-compress-1.10.jar:1.10]
	at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.<init>(GzipCompressorInputStream.java:100) ~[commons-compress-1.10.jar:1.10]
	at org.jfrog.repomd.npm.NpmMetadataExtractor.read(NpmMetadataExtractor.java:95) ~[npm-4.3.25.jar:na]
	... 80 common frames omitted
....

and request.log:

20170501081530|61|REQUEST|82.81.195.5|admin|GET|/api/npm/npm/equals|HTTP/1.1|500|0
20170501081541|63|REQUEST|82.81.195.5|admin|GET|/api/npm/npm/equals|HTTP/1.1|500|0
20170501081642|61|REQUEST|82.81.195.5|admin|GET|/api/npm/npm/equals|HTTP/1.1|500|0

The issue occurs regardless to any whitelisted pattern.
As a workaround either disabling the External Dependency Rewrite, or resolving directly from the remote repository works.



 Comments   
Comment by Martin Voegeli [ 21/Dec/17 ]

We encountered a similar problem with this setup:

  • Simple NPM mirror to https://registry.npmjs.org
  • Outbound proxy on premise might have had some operational issue
  • Request.log shows statements like [1] and errors like [3]
  • The artifact browser shows a directory instead of a document in the cache repository.
  • Deleting directory in the cache and resolve again fixes the problem.

Form an operational perspective this is a unstable and support intensive behavior.
Would be more than nice to fix this and document workarounds here (we assume the 'Block Mismatching Mime Types' might provide a workaround here).

Our setup:

  • artifactory/5.6.3 (current latest version)
  • tested with node-v6.10.3-linux-x64 [2]
  • We do not have a virtual repository with enabled 'External Dependency Rewrite' as mentioned above.
  • We have HTTP/406 instead of HTTP/500 but seems to be the same issue.

Our expectation:

  • Artifactory validates remote content.
  • If content fails validation, do not cache, assuming it's a temporary problem and a retry later might fix it.

Thanks
martin

[1]

20171221112738|5|REQUEST|192.168.14.142|anonymous|GET|/npmjs-npm-re/bluebird/|HTTP/1.0|406|0

[2]

env | grep -i proxy
=> none set, so not fallback to Internet
node-v6.10.3-linux-x64/bin/node node-v6.10.3-linux-x64/lib/node_modules/npm/bin/npm-cli.js install -ddd karma@1.1.1 --registry=https://....
=> requires trust anchor to be correctly configured, otherwise node will not like you

[3]

2017-12-21 11:27:38,074 [http-nio-8081-exec-12] [INFO ] (o.a.r.HttpRepo      :432) - npmjs-npm-re downloaded  https://registry.npmjs.org/karma 1.40 MB at 13,403.72 KB/sec
2017-12-21 11:27:38,137 [http-nio-8081-exec-12] [ERROR] (o.j.r.n.NpmMetadataExtractor:118) - Unable to find or parse correctly the package archive ('package.json') within the tarball content: Input is not in the .gz format
java.io.IOException: Input is not in the .gz format
        at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.init(GzipCompressorInputStream.java:162) ~[commons-compress-1.10.jar:1.10]
        at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.<init>(GzipCompressorInputStream.java:135) ~[commons-compress-1.10.jar:1.10]
        at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.<init>(GzipCompressorInputStream.java:100) ~[commons-compress-1.10.jar:1.10]
        at org.jfrog.repomd.npm.NpmMetadataExtractor.read(NpmMetadataExtractor.java:104) [npm-4.3.42.jar:na]
        at org.jfrog.repomd.npm.NpmMetadataExtractor.extractAsSystem(NpmMetadataExtractor.java:55) [npm-4.3.42.jar:na]
        at org.jfrog.repomd.npm.NpmMetadataExtractor.extract(NpmMetadataExtractor.java:42) [npm-4.3.42.jar:na]
        at org.artifactory.addon.npm.NpmServiceImpl.getNpmMetadata(NpmServiceImpl.java:78) [artifactory-addon-npm-5.6.3.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
        at com.sun.proxy.$Proxy216.getNpmMetadata(Unknown Source) [na:na]
        at org.artifactory.addon.npm.repo.remote.NpmRemoteInterceptor.afterRemoteDownload(NpmRemoteInterceptor.java:57) [artifactory-addon-npm-5.6.3.jar:na]
        at org.artifactory.repo.RemoteRepoBase.notifyInterceptorsOnAfterRemoteDownload(RemoteRepoBase.java:661) [artifactory-core-5.6.3.jar:na]
        at org.artifactory.repo.RemoteRepoBase.downloadAndSave(RemoteRepoBase.java:603) [artifactory-core-5.6.3.jar:na]
        at org.artifactory.repo.service.RepositoryServiceImpl.downloadAndSave(RepositoryServiceImpl.java:1677) [artifactory-core-5.6.3.jar:na]
        at sun.reflect.GeneratedMethodAccessor950.invoke(Unknown Source) ~[na:na]
Comment by Inbar Tal (Inactive) [ 21/Dec/17 ]

The bug is Fixed. We had a problem to perform rewriting for one of the transitive dependencies of the package 'equals'. This specific dependency url is not part of the npm spec and therefore we didn't support it.
The second bug I fixed is related to the 'gitrefs' file. Its a text file that we get from github/bitbucket when we perform the dependency rewriting.
The bug was that we treated it like a tar.gz and not like a text file. Now this file is also expirable.(So QA should check this too)

Comment by Martin Voegeli [ 21/Dec/17 ]

Ok, sounds good. As you mention QA I assume this fix will come with artifactory/5.8.0 then. Thanks.

Generated at Tue Sep 22 18:18:41 UTC 2020 using Jira 8.5.3#805003-sha1:b4933e02eaff29a49114274fe59e1f99d9d963d7.