fix: catch OSError from fcntl.flock(LOCK_UN) in google_oauth.py - #30276
Closed
annguyenNous wants to merge 1 commit into
Closed
annguyenNous wants to merge 1 commit into
annguyenNous wants to merge 1 commit into
Conversation
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.
Contributor
This was referenced May 24, 2026
Collaborator
|
Thanks for identifying the missed Automated hermes-sweeper review found this is superseded on current
Closing as implemented on main because the vulnerable code path has been removed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
agent/google_oauth.py, thefcntlbranch of the file-lock release only catchesImportError, notOSError. Iffcntl.flock(fd, fcntl.LOCK_UN)raisesOSError(e.g.EBADF), the exception propagates uncaught through the outerfinallyblock, masking the original exception from theyieldbody.The
msvcrtbranch (line 236) already correctly catchesOSError, confirming this is an oversight — thefcntlbranch should mirror it.Fix
Change
except ImportError:toexcept (ImportError, OSError):on line 230 so both branches handle unlock failures consistently.Context
This is the same pattern that was fixed in 5 other files (PR #20529, #23819, #23873) —
agent/shell_hooks.py,tools/skill_usage.py,tools/memory_tool.py,tools/environments/file_sync.py,hermes_cli/auth.py. This instance ingoogle_oauth.pywas missed by those earlier scans because it's nested inside anexcept ImportErrorblock rather than a standalonefinally.