mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-11 16:08:58 +08:00
fix: improve error handling in NotionExtractor data fetching (#12182)
Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
parent
716bb8574d
commit
8d15c8cfbf
@ -138,17 +138,24 @@ class NotionExtractor(BaseExtractor):
|
|||||||
block_url = BLOCK_CHILD_URL_TMPL.format(block_id=page_id)
|
block_url = BLOCK_CHILD_URL_TMPL.format(block_id=page_id)
|
||||||
while True:
|
while True:
|
||||||
query_dict: dict[str, Any] = {} if not start_cursor else {"start_cursor": start_cursor}
|
query_dict: dict[str, Any] = {} if not start_cursor else {"start_cursor": start_cursor}
|
||||||
res = requests.request(
|
try:
|
||||||
"GET",
|
res = requests.request(
|
||||||
block_url,
|
"GET",
|
||||||
headers={
|
block_url,
|
||||||
"Authorization": "Bearer " + self._notion_access_token,
|
headers={
|
||||||
"Content-Type": "application/json",
|
"Authorization": "Bearer " + self._notion_access_token,
|
||||||
"Notion-Version": "2022-06-28",
|
"Content-Type": "application/json",
|
||||||
},
|
"Notion-Version": "2022-06-28",
|
||||||
params=query_dict,
|
},
|
||||||
)
|
params=query_dict,
|
||||||
data = res.json()
|
)
|
||||||
|
if res.status_code != 200:
|
||||||
|
raise ValueError(f"Error fetching Notion block data: {res.text}")
|
||||||
|
data = res.json()
|
||||||
|
except requests.RequestException as e:
|
||||||
|
raise ValueError("Error fetching Notion block data") from e
|
||||||
|
if "results" not in data or not isinstance(data["results"], list):
|
||||||
|
raise ValueError("Error fetching Notion block data")
|
||||||
for result in data["results"]:
|
for result in data["results"]:
|
||||||
result_type = result["type"]
|
result_type = result["type"]
|
||||||
result_obj = result[result_type]
|
result_obj = result[result_type]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user