fix: route HttpProxySink timeouts through spool fallback#3647
Open
atimothee wants to merge 1 commit into
Open
Conversation
`HttpProxySink._post()` only caught `HTTPError` and `URLError`, so a `TimeoutError` (e.g. a socket-level connect timeout) bypassed the configured spool path and surfaced the raw exception to callers. Catch `TimeoutError` and `OSError` alongside the existing URL errors so the spool write and the sink's `RuntimeError` wrapper are exercised consistently for all delivery failures, and add a regression test that patches `urlopen` to raise each error type. Fixes openai#3641
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.
Summary
HttpProxySink._post()only caughtHTTPErrorandURLError, so aTimeoutError(for example a socket-level connect timeout, or any other low-levelOSErrorsuch asConnectionRefusedError) bypassed the configuredspool_pathfallback and surfaced the raw exception to callers instead of the sink'sRuntimeErrorwrapper.This change catches
TimeoutErrorandOSErroralongside the existing URL errors so the spool write and the sink'sRuntimeErrorwrapper are exercised consistently for every delivery failure, restoring the configured fallback behavior. A short comment documents why the wider exception list is intentional.Test plan
tests/sandbox/test_session_sinks.py::test_http_proxy_sink_writes_spool_on_timeout_or_oserror) that patchesurllib.request.urlopenin the sinks module to raiseTimeoutErrorandOSErrorin turn, asserts the sink raisesRuntimeErrorwith the expected message, and asserts the spool file contains the serialized event line.uv run pytest tests/sandbox/test_session_sinks.py -v -k test_http_proxy_sink_writes_spool_on_timeout_or_oserror(both parametrized cases pass).uv run pytest tests/sandbox/ -q— 806 passed, 19 skipped (no regressions).make formatanduv run ruff check/uv run mypy/uv run pyrightagainst the changed files — all clean.Issue number
Closes #3641
Checks
make lintandmake formatMade with Cursor