Skip to content

Don't crash when Linode returns an invalid JSON#6

Open
Matheus28 wants to merge 1 commit intohoratio-sans-serif:masterfrom
Matheus28:patch-1
Open

Don't crash when Linode returns an invalid JSON#6
Matheus28 wants to merge 1 commit intohoratio-sans-serif:masterfrom
Matheus28:patch-1

Conversation

@Matheus28
Copy link

Sometimes, because of 5xx errors, Linode doesn't actually return a JSON, but an error string. That causes linode-api to crash. This patch fixes this by forwarding an invalid JSON error to the callback.

Please notice that I don't actually write in Coffeescript, but the code should be correct (it's equivalent to the change I made locally directly to the .js file to fix this).

Sometimes, because of 5xx errors, Linode doesn't actually return a JSON, but an error string. That causes linode-api to crash. This patch fixes this by forwarding an invalid JSON error to the callback.

Please notice that I don't actually write in Coffeescript, but the code should be correct (it's equivalent to the change I made locally directly to the .js file to fix this).
@Matheus28
Copy link
Author

Actually, what is happening isn't exactly invalid JSON. But the Linode API replies with no body, and body = undefined, so it JSON.parse stringifies it and that's where the "invalid JSON" comes from. The fix still stands, though.

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

Successfully merging this pull request may close these issues.

1 participant