consolidate the retry mechanism into the handle_http_errors decorator, mitigates idempotency risks by limiting retries to read-only operations

This commit is contained in:
Taylor Wilsdon
2025-07-17 13:57:21 -04:00
parent 181ffb650d
commit f08373a8b2
9 changed files with 116 additions and 165 deletions

View File

@@ -13,16 +13,15 @@ from googleapiclient.http import MediaIoBaseDownload
# Auth & server utilities
from auth.service_decorator import require_google_service, require_multiple_services
from core.utils import extract_office_xml_text, handle_http_errors, retry_on_ssl_error
from core.utils import extract_office_xml_text, handle_http_errors
from core.server import server
from core.comments import create_comment_tools
logger = logging.getLogger(__name__)
@server.tool()
@handle_http_errors("search_docs", is_read_only=True)
@require_google_service("drive", "drive_read")
@handle_http_errors("search_docs")
@retry_on_ssl_error()
async def search_docs(
service,
user_google_email: str,
@@ -58,12 +57,11 @@ async def search_docs(
return "\n".join(output)
@server.tool()
@handle_http_errors("get_doc_content", is_read_only=True)
@require_multiple_services([
{"service_type": "drive", "scopes": "drive_read", "param_name": "drive_service"},
{"service_type": "docs", "scopes": "docs_read", "param_name": "docs_service"}
])
@handle_http_errors("get_doc_content")
@retry_on_ssl_error()
async def get_doc_content(
drive_service,
docs_service,
@@ -159,9 +157,8 @@ async def get_doc_content(
return header + body_text
@server.tool()
@handle_http_errors("list_docs_in_folder", is_read_only=True)
@require_google_service("drive", "drive_read")
@handle_http_errors("list_docs_in_folder")
@retry_on_ssl_error()
async def list_docs_in_folder(
service,
user_google_email: str,
@@ -192,9 +189,8 @@ async def list_docs_in_folder(
return "\n".join(out)
@server.tool()
@require_google_service("docs", "docs_write")
@handle_http_errors("create_doc")
@retry_on_ssl_error()
@require_google_service("docs", "docs_write")
async def create_doc(
service,
user_google_email: str,