Skip to content

Close response streams on terminal validation errors - #83

Open
bensynapse wants to merge 1 commit into
will-ockmore:mainfrom
bensynapse:fix-validator-response-cleanup
Open

bensynapse wants to merge 1 commit into
will-ockmore:mainfrom
bensynapse:fix-validator-response-cleanup

Conversation

@bensynapse

Copy link
Copy Markdown

I run Live Tennis API.

If validate_response raises ValueError, the transport raises before HTTPX receives the response. Its unread stream stays open.
Both transport paths now close the discarded response before raising. This also handles an asyncio task cancelled while validation is awaiting.
Retryable validation errors keep their existing retry flow. Successful streamed responses stay open for the caller.

Added seven cases using unread streams and a real cancelled task. Five fail on the original transport code.

scripts/test passes all 159 tests with 100% coverage on Python 3.10 through 3.14. scripts/check passes on all five versions.
scripts/build passes on Python 3.10 and 3.14, including the strict docs build.
The scripts/test-fork harness passes all 159 tests with HTTPX_BACKEND=httpxyz and HTTPX_BACKEND=httpx2 on Python 3.13.
httpxyz emits one pytest assertion rewrite warning.

@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (67c9725) to head (c322e53).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              main       #83    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            8         8            
  Lines         1460      1561   +101     
==========================================
+ Hits          1460      1561   +101     
Files with missing lines Coverage Δ
httpx_retries/transport.py 100.00% <100.00%> (ø)
tests/test_transport.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant