From 3c721cbaf210eed5a3b5bd90a62d1a80ce263047 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Tue, 31 Dec 2024 16:46:33 +0800 Subject: [PATCH] fix: improve error handling in NotionOAuth for block parent page ID retrieval Signed-off-by: -LAN- --- api/libs/oauth_data_source.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/libs/oauth_data_source.py b/api/libs/oauth_data_source.py index 0c872a0066d127..a5ba08d351c0cc 100644 --- a/api/libs/oauth_data_source.py +++ b/api/libs/oauth_data_source.py @@ -255,7 +255,8 @@ def notion_block_parent_page_id(self, access_token: str, block_id: str): response = requests.get(url=f"{self._NOTION_BLOCK_SEARCH}/{block_id}", headers=headers) response_json = response.json() if response.status_code != 200: - raise ValueError(f"Error fetching block parent page ID: {response_json.message}") + message = response_json.get("message", "unknown error") + raise ValueError(f"Error fetching block parent page ID: {message}") parent = response_json["parent"] parent_type = parent["type"] if parent_type == "block_id":