Skip to content

Address code review comments

25a953e
Select commit
Loading
Failed to load commit list.
Merged

feat(httpx): Migrate to span first #6084

Address code review comments
25a953e
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed Apr 17, 2026 in 4m 46s

2 issues

find-bugs: Found 2 issues (1 high, 1 medium)

High

Tests mock non-existent `legacy_start_span` - tests will not properly intercept span creation - `tests/integrations/httpx/test_httpx.py:625-627`

The tests test_no_request_source_if_duration_too_short_legacy and test_request_source_if_duration_over_threshold_legacy mock sentry_sdk.integrations.httpx.legacy_start_span, but this name does not exist in the httpx.py module. The integration uses sentry_sdk.start_span directly. When mock.patch patches a non-existent attribute, it creates the attribute but doesn't intercept the actual function call, meaning the span duration manipulation won't work and the tests won't validate what they claim to test.

Also found at:

  • tests/integrations/httpx/test_httpx.py:677-679

Medium

Test will fail for sync client due to inconsistent url.query/url.fragment handling - `tests/integrations/httpx/test_httpx.py:1198-1199`

The test test_http_url_attributes_no_query_or_fragment_span_streaming asserts that url.query and url.fragment should NOT be present when the URL has no query/fragment. However, the sync client implementation in httpx.py (lines 77-78) unconditionally sets these attributes, while the async client implementation (lines 184-187) conditionally sets them only when truthy. This test will pass for httpx.AsyncClient() but fail for httpx.Client() because the sync implementation always includes these attributes (with empty string values).

Also found at:

  • sentry_sdk/integrations/httpx.py:75-78

Duration: 4m 44s · Tokens: 5.0M in / 33.0k out · Cost: $8.23 (+extraction: $0.01, +merge: $0.00)

Annotations

Check failure on line 627 in tests/integrations/httpx/test_httpx.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

Tests mock non-existent `legacy_start_span` - tests will not properly intercept span creation

The tests `test_no_request_source_if_duration_too_short_legacy` and `test_request_source_if_duration_over_threshold_legacy` mock `sentry_sdk.integrations.httpx.legacy_start_span`, but this name does not exist in the httpx.py module. The integration uses `sentry_sdk.start_span` directly. When mock.patch patches a non-existent attribute, it creates the attribute but doesn't intercept the actual function call, meaning the span duration manipulation won't work and the tests won't validate what they claim to test.

Check failure on line 679 in tests/integrations/httpx/test_httpx.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

[MAJ-74T] Tests mock non-existent `legacy_start_span` - tests will not properly intercept span creation (additional location)

The tests `test_no_request_source_if_duration_too_short_legacy` and `test_request_source_if_duration_over_threshold_legacy` mock `sentry_sdk.integrations.httpx.legacy_start_span`, but this name does not exist in the httpx.py module. The integration uses `sentry_sdk.start_span` directly. When mock.patch patches a non-existent attribute, it creates the attribute but doesn't intercept the actual function call, meaning the span duration manipulation won't work and the tests won't validate what they claim to test.

Check warning on line 1199 in tests/integrations/httpx/test_httpx.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

Test will fail for sync client due to inconsistent url.query/url.fragment handling

The test `test_http_url_attributes_no_query_or_fragment_span_streaming` asserts that `url.query` and `url.fragment` should NOT be present when the URL has no query/fragment. However, the sync client implementation in `httpx.py` (lines 77-78) unconditionally sets these attributes, while the async client implementation (lines 184-187) conditionally sets them only when truthy. This test will pass for `httpx.AsyncClient()` but fail for `httpx.Client()` because the sync implementation always includes these attributes (with empty string values).

Check warning on line 78 in sentry_sdk/integrations/httpx.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

[SAZ-CR4] Test will fail for sync client due to inconsistent url.query/url.fragment handling (additional location)

The test `test_http_url_attributes_no_query_or_fragment_span_streaming` asserts that `url.query` and `url.fragment` should NOT be present when the URL has no query/fragment. However, the sync client implementation in `httpx.py` (lines 77-78) unconditionally sets these attributes, while the async client implementation (lines 184-187) conditionally sets them only when truthy. This test will pass for `httpx.AsyncClient()` but fail for `httpx.Client()` because the sync implementation always includes these attributes (with empty string values).