fix(streaming): catch OverflowError in _terminal_turn_duration so a huge/invalid pending_started_at can't abort terminal-error settlement
Codex gate on #6312 found the extracted helper caught only (TypeError, ValueError) while the inline code it replaced caught Exception; float(10**400) raises OverflowError, escaping the helper and aborting terminal-error cleanup before the error message is persisted / apperror is emitted. Widen _terminal_turn_duration's float() guard to (TypeError, ValueError, OverflowError) — the exact exceptions float() can raise. Adds 10**400 to the existing invalid-origin parametrize (red-before-green verified).
This commit is contained in:
parent
9bde2cf3af
commit
5ff16c59d4
2 changed files with 2 additions and 2 deletions
|
|
@ -6508,7 +6508,7 @@ def _terminal_turn_duration(session, *, now: float | None = None) -> float | Non
|
|||
try:
|
||||
started = float(started_at)
|
||||
ended = float(time.time() if now is None else now)
|
||||
except (TypeError, ValueError):
|
||||
except (TypeError, ValueError, OverflowError):
|
||||
return None
|
||||
if not math.isfinite(started) or not math.isfinite(ended) or started <= 0:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import api.streaming as streaming
|
|||
from api.models import Session
|
||||
|
||||
|
||||
@pytest.mark.parametrize("started_at", [None, 0, -1, "invalid", float("nan"), float("inf"), 101.0])
|
||||
@pytest.mark.parametrize("started_at", [None, 0, -1, "invalid", float("nan"), float("inf"), 101.0, 10**400])
|
||||
def test_terminal_turn_duration_omits_invalid_origin(started_at):
|
||||
session = types.SimpleNamespace(pending_started_at=started_at)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue