open-services / open-registry

Community Owned JavaScript Registry
https://open-registry.dev
MIT License
266 stars 8 forks source link

Make sure 404s from registry.npmjs.org gets 404 response from open-registry #29

Open victorb opened 5 years ago

victorb commented 5 years ago

Currently, doing the following renders a 404:

$ wget https://registry.npmjs.org/emitter/-/emitter-1.2.1.tgz
--2019-05-01 18:03:12--  https://registry.npmjs.org/emitter/-/emitter-1.2.1.tgz
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving registry.npmjs.org (registry.npmjs.org)... 104.16.23.35, 104.16.19.35, 104.16.25.35, ...
Connecting to registry.npmjs.org (registry.npmjs.org)|104.16.23.35|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-05-01 18:03:13 ERROR 404: Not Found.

But if we try to get the same tarball from open-registry, it fails with a 500 instead of 404.

$ wget https://npm.open-registry.dev/emitter/-/emitter-1.2.1.tgz
--2019-05-01 18:03:32--  https://npm.open-registry.dev/emitter/-/emitter-1.2.1.tgz
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving npm.open-registry.dev (npm.open-registry.dev)... 136.243.78.134, 2a01:4f8:212:2c9d::2
Connecting to npm.open-registry.dev (npm.open-registry.dev)|136.243.78.134|:443... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2019-05-01 18:03:32 ERROR 500: Internal Server Error.

In this specific case we need to make sure the handler for tarballs, when making a request to npm, also returns the 404 if it happens. This would be done here: https://github.com/open-services/open-registry/blob/master/src/open_registry/http.clj#L55

Also need to make sure it's working the same for getting the metadata.