Skip to content

fix: Re-add httpcore[asyncio] to tox.ini and fix renamed import

9b0a712
Select commit
Loading
Failed to load commit list.
Merged

feat: Add experimental async transport (port of PR #4572) #5646

fix: Re-add httpcore[asyncio] to tox.ini and fix renamed import
9b0a712
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Mar 27, 2026 in 17m 50s

9 issues

High

test_async_transport_concurrent_requests missing required pytest decorators - `tests/test_transport.py:1058-1077`

The test function test_async_transport_concurrent_requests is missing @skip_under_gevent, @pytest.mark.asyncio, and @pytest.mark.skipif(not PY38, ...) decorators that all other async transport tests in this file have. Without @pytest.mark.asyncio, the test will fail or be skipped by pytest-asyncio. Without @skip_under_gevent, the test will run under gevent where async tests are incompatible. Without the Python version skip, the test will fail on Python < 3.8.

Medium

Test will fail: close() uses warnings.warn but test expects logger.warning - `sentry_sdk/client.py:1049-1052`

The close() method uses warnings.warn() with message 'close() used with AsyncHttpTransport. Use close_async() instead.' but the corresponding test test_close_with_async_transport_warns expects logger.warning() with a different message. This will cause the test to fail. Either change to logger.warning() to match the test expectation, or update the test to use pytest.warns() to capture warnings.

Also found at:

  • sentry_sdk/client.py:1095-1100
  • tests/test_client.py:1669-1674
  • tests/test_client.py:1737-1741
Test mocking does not satisfy isinstance check, causing test to not verify intended behavior - `tests/integrations/asyncio/test_asyncio.py:669-670`

The test test_loop_close_flushes_async_transport creates mock_transport = Mock(spec=AsyncHttpTransport), but the _flush() function in patch_loop_close() checks isinstance(client.transport, AsyncHttpTransport) which will return False for a Mock object, even with spec=. This means _flush() returns early without calling close_async(). The test assertions should fail, or if they pass, the test is not actually verifying the flush-on-close behavior it intends to test.

Also found at:

  • tests/test_transport.py:1058
httpcore[asyncio] dependency will fail on Python 3.6 and 3.7 - `scripts/populate_tox/tox.jinja:91`

The common: httpcore[asyncio] line at 91 adds the httpcore asyncio dependency for all Python versions, but httpcore 1.x requires Python >=3.8. Since the common test environment includes py3.6 and py3.7 (as defined on line 21), tox will fail to install dependencies for those environments. The dependency should be version-gated like other packages in this file (e.g., {py3.8,py3.9,py3.10,py3.11,py3.12,py3.13,py3.14,py3.14t}-common: httpcore[asyncio]).

Also found at:

  • sentry_sdk/client.py:1057
Late binding closure bug in AsyncWorker causes queue_ref to capture wrong queue - `sentry_sdk/worker.py:284`

The lambda on line 284 captures queue_ref by reference, not by value. Since queue_ref is reassigned in each loop iteration, all lambdas will see the most recent value of queue_ref when they execute, not the value at the time they were created. If kill()/start() replaces self._queue while tasks are pending, the callbacks will use the wrong queue, leading to calling task_done() on the wrong queue. This directly contradicts the comment on lines 281-282.

test_close_with_async_transport_warns mocks logger.warning but implementation uses warnings.warn - `tests/test_client.py:1671-1677`

The test mocks sentry_sdk.client.logger and asserts mock_logger.warning.assert_called_with(...), but the actual close() implementation at line 1049 uses warnings.warn() instead of logger.warning(). Additionally, the expected message differs from the actual message in the implementation. This test will always pass the assertion incorrectly because the mocked logger is never called.

Also found at:

  • tests/test_client.py:1737-1741
  • sentry_sdk/client.py:1049-1052
test_async_transport_concurrent_requests missing request fixture parameter - `tests/test_transport.py:1058-1060`

The test function test_async_transport_concurrent_requests is missing the request fixture parameter in its function signature. This parameter is needed to add a finalizer for proper cleanup of the global scope client, as is done in other similar async tests in this file (test_transport_works_async, test_async_transport_rate_limiting_with_concurrency).

Also found at:

  • tests/test_transport.py:1067

Low

test_async_transport_concurrent_requests doesn't clean up global client state - `tests/test_transport.py:1067`

The test sets the global client via sentry_sdk.get_global_scope().set_client(client) but never resets it to None after the test completes. All other similar tests in this file use either request.addfinalizer() or a try/finally block to reset the client. This can cause test pollution affecting subsequent tests.

Helper function `_make_async_transport_options` is never used - `tests/test_transport.py:55-73`

The helper function _make_async_transport_options() is defined at line 55 but is never called anywhere in the test file or the entire test suite. This appears to be dead code that was added but never integrated into any test. The async transport tests (e.g., test_transport_works_async) construct their options inline rather than using this helper.

4 skills analyzed
Skill Findings Duration Cost
code-review 3 15m 15s $7.70
find-bugs 6 12m 23s $15.11
skill-scanner 0 3m 47s $2.98
security-review 0 17m 44s $4.82

Duration: 49m 8s · Tokens: 18.4M in / 171.9k out · Cost: $30.77 (+extraction: $0.03, +merge: $0.01, +fix_gate: $0.02, +dedup: $0.10)