feat: add authentication expiration handling for Notion tools

- Implemented checks for expired authentication in the Notion page creation and deletion tools, returning appropriate error messages for re-authentication.
- Updated the Notion tool metadata service to track account health and persist authentication status, improving error handling and user feedback during operations.
This commit is contained in:
Anish Sarkar 2026-03-20 16:12:18 +05:30
parent db5fddb104
commit 10af5d3f3e
3 changed files with 42 additions and 2 deletions

View file

@ -95,8 +95,19 @@ def create_delete_notion_page_tool(
"message": error_msg,
}
account = context.get("account", {})
if account.get("auth_expired"):
logger.warning(
"Notion account %s has expired authentication",
account.get("id"),
)
return {
"status": "auth_error",
"message": "The Notion account for this page needs re-authentication. Please re-authenticate in your connector settings.",
}
page_id = context.get("page_id")
connector_id_from_context = context.get("account", {}).get("id")
connector_id_from_context = account.get("id")
document_id = context.get("document_id")
logger.info(

View file

@ -110,6 +110,17 @@ def create_update_notion_page_tool(
"message": error_msg,
}
account = context.get("account", {})
if account.get("auth_expired"):
logger.warning(
"Notion account %s has expired authentication",
account.get("id"),
)
return {
"status": "auth_error",
"message": "The Notion account for this page needs re-authentication. Please re-authenticate in your connector settings.",
}
page_id = context.get("page_id")
document_id = context.get("document_id")
connector_id_from_context = context.get("account", {}).get("id")