Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't fail gracefully on 404 response from registry #632

Closed
mattmazzola opened this issue Jan 31, 2018 · 2 comments
Closed

Doesn't fail gracefully on 404 response from registry #632

mattmazzola opened this issue Jan 31, 2018 · 2 comments

Comments

@mattmazzola
Copy link

mattmazzola commented Jan 31, 2018

Current behavior

I have semantic-release configured to a custom registry and the get-last-release plugin tries to get the last version published in order to know what the next version should be; however, this registry returns different body than the official npm registry (text rather than empty json) causing semantic-release to fail at parsing the body.

Example:

Custom registry returns 404 with text/html
Request: GET http://bbnpm.azurewebsites.net/non-existent-package
Response: 404 The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.`

Official registry returns 404 with application/json
Request: GET https://registry.npmjs.org/non-existent-package
Response: {}

This could be blamed on the custom registry that they don't return same response as official thus breaking API; however, neither of them respect the Accept header so it's probably not spec'd.
Either way, semantic release should have enough information to determine there is no last version because of the return code 404. It also could look at the Content-Type header to know how/when to parse the body.

The custom registry looks like: http://www.verdaccio.org/ but I'm not very familiar with that.

Expected behavior

If the return code is 404 it should assume the package doesn't exist and no try to parse the body.

Environment

@pvdlg
Copy link
Member

pvdlg commented Jan 31, 2018

Yes this is one of the numerous problems we had trying to integrate with various npm registries. As there is no specifications, all "npm compatible" registries have different behavior.

For this reason and others we don't use the npm registry anymore to retrieve the last release. We now rely on Git tags. See #613.

This PR has been released in the @next dist-tag. You can use it with semantic-release 13.0.0.

@pvdlg
Copy link
Member

pvdlg commented Feb 5, 2018

I'm going to go ahead and close this issue as the getLastRelease plugin doesn't exist anymore in [email protected] so the problematic code is not there anymore.

I recommend to upgrade to [email protected] which available on the @next dist-tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants