Skip to content

Commit 767517e

Browse files
committed
handle empty responses w/ errors
1 parent c6fb387 commit 767517e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

twarc/expansions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ def ensure_flattened(data):
242242
log.warning(f"Unable to expand dictionary without includes: {data}")
243243
return flatten(data)
244244

245+
# If it's just an object with errors return an empty list
246+
elif (
247+
isinstance(data, dict)
248+
and "data" not in data
249+
and "includes" not in data
250+
and "errors" in data
251+
):
252+
return []
253+
245254
# If it's a single response and both "includes" and "data" are missing, it is already flattened
246255
elif isinstance(data, dict) and "data" not in data and "includes" not in data:
247256
return [data]

0 commit comments

Comments
 (0)