Skip to content

Handle empty responses in timeline search#62

Merged
alex9smith merged 2 commits intomainfrom
handle-empty-responses-timeline
Mar 31, 2025
Merged

Handle empty responses in timeline search#62
alex9smith merged 2 commits intomainfrom
handle-empty-responses-timeline

Conversation

@alex9smith
Copy link
Owner

Some timeline searches return no results - particularly those with a short timespan. The API response when there's no results is simply {} and not the {"timeline": []} that this library was expecting.

This meant users got a KeyError whenever they made a search that returned new results.

I'm not clear if GDELT changed thier API response format since I originally wrote the handling for the empty case or if this is simply a long-running bug that's finally been brought to my notice and addressed.

Fixes #58

Some timeline searches return no results - particularly those with a
short timespan. The API response when there's no results is simply `{}`
and not the `{"timeline": []}` that this library was expecting.

This meant users got a KeyError whenever they made a search that
returned new results.

I'm not clear if GDELT changed thier API response format since I
originally wrote the handling for the empty case or if this is simply a
long-running bug that's finally been brought to my notice and addressed.

Fixes #58
@alex9smith alex9smith merged commit 456334f into main Mar 31, 2025
2 checks passed
@alex9smith alex9smith deleted the handle-empty-responses-timeline branch March 31, 2025 11:16
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.

timeline_search fails with KeyError: 'timeline' in version 1.10.1

1 participant