NVD API sometimes returns gibberish
raboof opened this issue · comments
After a number of successful fetches I sometimes see:
ERROR
io.github.jeremylong.nvdlib.NvdApiException: Failed to parse JSON starting with: "??`I?%&/m?{J?J??t?`$??@???????iG#)?*??eVe]f@??????{????{????;?N'????\fdl??J???!?"
at io.github.jeremylong.nvdlib.NvdCveApi.next(NvdCveApi.java:294)
I haven't verified whether the NVD API is really returning gibberish or that there's something going wrong on the application side. I did check that the response has an application/json
content type as usual.
I'm gong to bet we can do better here:
Instead of just using the getBodyBytes()
we should validate it is correct. In cases that I have seen the getBody()
return null - there was actual JSON in the getBodyBytes()
...
I added a log statement and when it happened again the jibberish came from getBodyText
.
so we'll need to put a retry if we get gibberish... love stable APIs.
while the underlying HTTP request will return garbage - the updated library will retry automatically.