feat: Add experimental async transport (port of PR #4572) #5646
4 issues
find-bugs: Found 4 issues (1 high, 2 medium, 1 low)
High
Test imports non-existent constant ASYNC_TRANSPORT_ENABLED causing ImportError - `tests/integrations/asyncio/test_asyncio.py:648`
The test imports ASYNC_TRANSPORT_ENABLED from sentry_sdk.transport, but this constant does not exist. The transport module only defines ASYNC_TRANSPORT_AVAILABLE (lines 34-36). This will cause an ImportError at runtime, making the test test_loop_close_flushes_async_transport fail immediately.
Also found at:
sentry_sdk/transport.py:980-988
Medium
Implementation uses warnings.warn() but tests expect logger.warning() - `sentry_sdk/client.py:1049-1052`
The close() and flush() methods use Python's warnings.warn() to emit deprecation-style warnings when called with an AsyncHttpTransport (lines 1049-1051 and 1096-1098). However, the corresponding tests (test_close_with_async_transport_warns and test_flush_with_async_transport_warns) mock sentry_sdk.client.logger and assert on logger.warning.assert_called_with(). This mismatch means the tests will fail since warnings.warn() and logger.warning() are different mechanisms - one raises Python warnings caught by pytest's warning capture, the other logs via the logging framework.
Also found at:
tests/test_client.py:1671-1677tests/test_client.py:1737-1741
Missing @pytest.mark.asyncio decorator causes test to not run - `tests/test_transport.py:1058`
The test test_async_transport_concurrent_requests is an async function but is missing the @pytest.mark.asyncio decorator. Without this decorator, pytest will not properly await the async function in most configurations, causing the test to either fail or silently pass without actually executing the test body. Other async tests in this file consistently have this decorator.
Low
In-place mutation of user-provided socket_options list - `sentry_sdk/transport.py:550-560`
In _get_httpcore_pool_options, when self.options["socket_options"] is provided and keep_alive is True, the code directly appends to the user-provided list instead of creating a copy. This mutates the original options dictionary, causing keep-alive socket options to accumulate if the method is called multiple times. While not a security vulnerability, this can cause unexpected behavior and resource issues.
Also found at:
sentry_sdk/transport.py:91-93
Duration: 13m 4s · Tokens: 9.4M in / 64.1k out · Cost: $14.09 (+extraction: $0.01, +merge: $0.00, +fix_gate: $0.01)
Annotations
Check failure on line 648 in tests/integrations/asyncio/test_asyncio.py
sentry-warden / warden: find-bugs
Test imports non-existent constant ASYNC_TRANSPORT_ENABLED causing ImportError
The test imports `ASYNC_TRANSPORT_ENABLED` from `sentry_sdk.transport`, but this constant does not exist. The transport module only defines `ASYNC_TRANSPORT_AVAILABLE` (lines 34-36). This will cause an `ImportError` at runtime, making the test `test_loop_close_flushes_async_transport` fail immediately.
Check failure on line 988 in sentry_sdk/transport.py
sentry-warden / warden: find-bugs
[LAZ-S4X] Test imports non-existent constant ASYNC_TRANSPORT_ENABLED causing ImportError (additional location)
The test imports `ASYNC_TRANSPORT_ENABLED` from `sentry_sdk.transport`, but this constant does not exist. The transport module only defines `ASYNC_TRANSPORT_AVAILABLE` (lines 34-36). This will cause an `ImportError` at runtime, making the test `test_loop_close_flushes_async_transport` fail immediately.
Check warning on line 1052 in sentry_sdk/client.py
sentry-warden / warden: find-bugs
Implementation uses warnings.warn() but tests expect logger.warning()
The `close()` and `flush()` methods use Python's `warnings.warn()` to emit deprecation-style warnings when called with an AsyncHttpTransport (lines 1049-1051 and 1096-1098). However, the corresponding tests (`test_close_with_async_transport_warns` and `test_flush_with_async_transport_warns`) mock `sentry_sdk.client.logger` and assert on `logger.warning.assert_called_with()`. This mismatch means the tests will fail since `warnings.warn()` and `logger.warning()` are different mechanisms - one raises Python warnings caught by pytest's warning capture, the other logs via the logging framework.
Check warning on line 1677 in tests/test_client.py
sentry-warden / warden: find-bugs
[ZXY-EQ2] Implementation uses warnings.warn() but tests expect logger.warning() (additional location)
The `close()` and `flush()` methods use Python's `warnings.warn()` to emit deprecation-style warnings when called with an AsyncHttpTransport (lines 1049-1051 and 1096-1098). However, the corresponding tests (`test_close_with_async_transport_warns` and `test_flush_with_async_transport_warns`) mock `sentry_sdk.client.logger` and assert on `logger.warning.assert_called_with()`. This mismatch means the tests will fail since `warnings.warn()` and `logger.warning()` are different mechanisms - one raises Python warnings caught by pytest's warning capture, the other logs via the logging framework.
Check warning on line 1741 in tests/test_client.py
sentry-warden / warden: find-bugs
[ZXY-EQ2] Implementation uses warnings.warn() but tests expect logger.warning() (additional location)
The `close()` and `flush()` methods use Python's `warnings.warn()` to emit deprecation-style warnings when called with an AsyncHttpTransport (lines 1049-1051 and 1096-1098). However, the corresponding tests (`test_close_with_async_transport_warns` and `test_flush_with_async_transport_warns`) mock `sentry_sdk.client.logger` and assert on `logger.warning.assert_called_with()`. This mismatch means the tests will fail since `warnings.warn()` and `logger.warning()` are different mechanisms - one raises Python warnings caught by pytest's warning capture, the other logs via the logging framework.
Check warning on line 1058 in tests/test_transport.py
sentry-warden / warden: find-bugs
Missing @pytest.mark.asyncio decorator causes test to not run
The test `test_async_transport_concurrent_requests` is an async function but is missing the `@pytest.mark.asyncio` decorator. Without this decorator, pytest will not properly await the async function in most configurations, causing the test to either fail or silently pass without actually executing the test body. Other async tests in this file consistently have this decorator.