-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Meaningful error message on malformed registry response #1356
Conversation
@@ -24,6 +24,10 @@ export default class NpmResolver extends RegistryResolver { | |||
static registry = 'npm'; | |||
|
|||
static async findVersionInRegistryResponse(config: Config, range: string, body: RegistryResponse): Promise<Manifest> { | |||
if (!body['dist-tags']) { | |||
throw new MessageError(`Received malformed response from registry. The registry may be down.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to use this.reporter.lang
, look for other uses in the codebase to see what I mean
@@ -24,6 +24,10 @@ export default class NpmResolver extends RegistryResolver { | |||
static registry = 'npm'; | |||
|
|||
static async findVersionInRegistryResponse(config: Config, range: string, body: RegistryResponse): Promise<Manifest> { | |||
if (!body['dist-tags']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check feels very loose. I wonder if we can do better or if this is the best we can do...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same thing, but I believe this is possibly the best indicator of a well-formed response, given what we want. Definitely open to suggestions, but I was specifically trying to avoid an error slightly lower down where body['dist-tags']
is undefined
.
@@ -24,6 +24,10 @@ export default class NpmResolver extends RegistryResolver { | |||
static registry = 'npm'; | |||
|
|||
static async findVersionInRegistryResponse(config: Config, range: string, body: RegistryResponse): Promise<Manifest> { | |||
if (!body['dist-tags']) { | |||
throw new MessageError(config.reporter.lang('malformedRegistryResponse')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thejameskyle Looking better, hopefully? Thanks for the review =)
@@ -1,5 +1,5 @@ | |||
HTTP/1.1 200 OK | |||
Date: Wed, 19 Oct 2016 13:30:48 GMT | |||
Date: Mon, 24 Oct 2016 13:03:20 GMT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be in the .gitignore
, but I'm not sure what the generalized entry would be.
Currently I'm facing the same issue. Is there any time frame when it will be part of a official release? Thanks ... and great work! |
Summary
When the yarn DNS failed to resolve today, a malformed response from the registry caused a cryptic error (see #1348) rather than a meaningful message.
Sorry for no test plan; this is a simple commit, but I wouldn't know how to reproduce it.
npm test
still works, so it doesn't break anything. =)