biomunky / newsapi

An API for interacting with the News API
MIT License
7 stars 2 forks source link

article.title Option<> for missing instances #33

Closed Aleksandr-Gamble closed 1 year ago

Aleksandr-Gamble commented 1 year ago

On rare occasion, the article.title field is missing. This leads to a panic on deserialization. Changing the .title field from String to Option fixes this.

As evidence, a diagnostic was performed where the same request was made with python requests. Note the NONE field in one of 100 articles:

[ type(article['title']).name for article in r.json()['articles'] ] ['str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'NoneType', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str']