Do not assume results key present in notion content when indexing

This commit is contained in:
Debanjum Singh Solanky 2024-04-15 08:01:36 +05:30
parent 4977b55106
commit d5de59d411

View file

@ -100,7 +100,7 @@ class NotionToEntries(TextToEntries):
for response in responses:
with timer("Processing response", logger=logger):
pages_or_databases = response["results"] if response.get("results") else []
pages_or_databases = response.get("results", [])
# Get all pages content
for p_or_d in pages_or_databases:
@ -125,7 +125,7 @@ class NotionToEntries(TextToEntries):
current_entries = []
curr_heading = ""
for block in content["results"]:
for block in content.get("results", []):
block_type = block.get("type")
if block_type == None:
@ -178,7 +178,7 @@ class NotionToEntries(TextToEntries):
return f"\n<b>{heading}</b>\n"
def process_nested_children(self, children, raw_content, block_type=None):
results = children["results"] if children.get("results") else []
results = children.get("results", [])
for child in results:
child_type = child.get("type")
if child_type == None: