From 4c496d3cf66d4b50882fad07bbafcdf19f5d2c8c Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Mon, 31 Aug 2026 06:23:54 -0700 Subject: [PATCH] fix(buzz): reconcile probe-race contract with shared file-attachment sender #95688's _send_file_attachment refactor re-probed file existence, which #74999's tests prove can race into a false 'not found' when the file disappears between the caller's check and the helper's. Callers that already verified the file pass probe=False; unverified document/video/ voice callers keep the guard. --- plugins/platforms/buzz/adapter.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/platforms/buzz/adapter.py b/plugins/platforms/buzz/adapter.py index f549d8ea8d..3efa2a6ff5 100644 --- a/plugins/platforms/buzz/adapter.py +++ b/plugins/platforms/buzz/adapter.py @@ -1464,6 +1464,7 @@ class BuzzAdapter(BasePlatformAdapter): caption=caption, reply_to=reply_to, metadata=metadata, + probe=False, ) # Markdown renders in Buzz, so a URL arrives as a clickable image link. text = f"{caption}\n{image_url}" if caption else image_url @@ -1477,10 +1478,16 @@ class BuzzAdapter(BasePlatformAdapter): caption: Optional[str] = None, reply_to: Optional[str] = None, metadata: Optional[Dict[str, Any]] = None, + probe: bool = True, ) -> SendResult: - """Upload a local file and publish it as a native Buzz attachment.""" + """Upload a local file and publish it as a native Buzz attachment. + + ``probe=False`` skips the existence re-check when the caller already + verified the file — a second probe could race into a false + "not found" if the file disappears between checks (#74999). + """ local = Path(file_path).expanduser() - if not local.is_file(): + if probe and not local.is_file(): return SendResult(success=False, error=f"File not found: {local}") args = [ "messages", "send", @@ -1535,6 +1542,7 @@ class BuzzAdapter(BasePlatformAdapter): caption=caption, reply_to=reply_to, metadata=metadata, + probe=False, ) return await super().send_image_file( chat_id=chat_id,