From 67c78ef7cb88ea44e7263df2cb0cf9acb0e25f68 Mon Sep 17 00:00:00 2001 From: annguyenNous Date: Fri, 22 May 2026 13:58:54 +0700 Subject: [PATCH] fix: catch OSError from fcntl.flock(LOCK_UN) in google_oauth.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fcntl branch of the file-lock release only caught ImportError, not OSError. If flock(LOCK_UN) raises OSError (e.g. EBADF), the exception propagates uncaught through the outer finally block, masking the original exception from the yield body. The msvcrt branch (line 236) already correctly catches OSError, confirming this is an oversight — the fcntl branch should mirror it. Fix: change 'except ImportError' to 'except (ImportError, OSError)' so both branches handle unlock failures consistently. --- agent/google_oauth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/google_oauth.py b/agent/google_oauth.py index 6f45c370f6caa..26951681680ee 100644 --- a/agent/google_oauth.py +++ b/agent/google_oauth.py @@ -227,7 +227,7 @@ def _credentials_lock(timeout_seconds: float = LOCK_TIMEOUT_SECONDS): import fcntl fcntl.flock(fd, fcntl.LOCK_UN) - except ImportError: + except (ImportError, OSError): try: import msvcrt # type: ignore[import-not-found]