Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix: Handle missing or null 'items' key in DataForSEO Related Keywords block (#10989)

seer-by-sentry[bot]e26822998ff0
diff --git a/autogpt_platform/backend/backend/blocks/dataforseo/related_keywords.py b/autogpt_platform/backend/backend/blocks/dataforseo/related_keywords.py
index 7a7fbdd11a..0757cb6507 100644
--- a/autogpt_platform/backend/backend/blocks/dataforseo/related_keywords.py
+++ b/autogpt_platform/backend/backend/blocks/dataforseo/related_keywords.py
@@ -182,13 +182,10 @@ class DataForSeoRelatedKeywordsBlock(Block):
if results and len(results) > 0:
# results is a list, get the first element
first_result = results[0] if isinstance(results, list) else results
- items = (
- first_result.get("items", [])
- if isinstance(first_result, dict)
- else []
- )
- # Ensure items is never None
- if items is None:
+ # Handle missing key, null value, or valid list value
+ if isinstance(first_result, dict):
+ items = first_result.get("items") or []
+ else:
items = []
for item in items:
# Extract keyword_data from the item