Skip to content

fix: preserve HTTPX response streams during instrumentation#15

Open
shreyas70 wants to merge 6 commits into
harness:mainfrom
shreyas70:fix/httpx-non-consuming-response-hooks
Open

fix: preserve HTTPX response streams during instrumentation#15
shreyas70 wants to merge 6 commits into
harness:mainfrom
shreyas70:fix/httpx-non-consuming-response-hooks

Conversation

@shreyas70

Copy link
Copy Markdown
Contributor

Summary

HTTPX response hooks previously drained the transport response stream to capture its body, then replaced HTTPX's private `_httpcore_stream` state with replay data. That buffered streaming responses, depended on private internals, and could leave streams partially consumed when capture failed.

This change removes that unsafe response-stream consumption and private mutation for all synchronous and asynchronous HTTPX responses.

Behavior change

  • HTTPX spans no longer capture `http.response.body`.
  • HTTPX response headers and status remain captured.
  • HTTPX request headers and body capture remain unchanged.
  • Response hooks pass `None` to `generic_response_handler` and never iterate or replace response streams.
  • Obsolete response draining, decoding, and replay helpers are removed.

This removes unsafe stream handling implicated by instrumentation. It does not, by itself, prove the production gzip issue's complete causality.

Verification

  • Focused TDD regression tests: observed 2 expected failures before implementation, then 2 passed.
  • Complete HTTPX suite: 5 passed, 2 existing deprecation warnings.
  • Non-database unit suite: 185 passed, 1 skipped, 24 warnings.
  • `python -m compileall -q src/harness_sdk`: passed.
  • `pylint src/harness_sdk --disable=C,R --ignore-patterns=config_pb2.py`: 10.00/10.
  • `git diff --check origin/main...HEAD`: passed.

Database integration tests were excluded because they require the repository's Docker services.

Made with Cursor

shreyas-n-harness and others added 6 commits July 17, 2026 14:20
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
These internal design/plan artifacts should not ship with the SDK change.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants