fix(cron): catch ValueError on os.open in lifecycle guard - #77974
fix(cron): catch ValueError on os.open in lifecycle guard#77974Braincramps wants to merge 1 commit into
Conversation
lifecycle_guard's _read_referenced_script only caught OSError around
os.open(), but a path containing a NUL byte raises ValueError ("embedded
null byte"). When the model emits such a path in a terminal command, the
uncaught ValueError propagates out of the guard and hangs the whole turn
for minutes (~17m observed) while the agent waits on a dead scan.
Catch (OSError, ValueError) and return (None, False) so a malformed path is
skipped gracefully instead of stalling the turn.
Duplicate of #77729: it contains the same |
|
Closing as superseded by #80258, which fixes this whole bug class architecturally rather than per-callsite: path candidates are sanitized once at the ingestion boundary (NUL/empty/unexpandable tokens rejected before any OS call), text from any Your report and fix targeted a real member of this class — thank you. The per-callsite patches kept leaving sibling frames exposed (#76762 → #77703 → #77780 → #78256 each crashed one frame away from the previous fix), which is why we went with the boundary fix instead of merging the fragments individually. #80258 carries regression tests for the NUL-path, binary-callback, oversized-read, unset-HOME, and walk-crash cases plus an adversarial never-raises sweep. |
Summary
Fixes the null-byte hang in cron/lifecycle_guard.py that can freeze an agent turn for minutes.
Problem
_read_referenced_scriptcallsos.open(path)but only caughtOSError.Fix
Catch
(OSError, ValueError)and return(None, False)so a malformed path is skipped gracefully instead of stalling the turn. Line 260 is the onlyos.opencall site in the file, so this single patch covers the guard.Verification
os.openon a null-byte path previously raised ValueError; now returns gracefully.os.opencall sites.