Skip to content

refactor: Address reviewer feedback — rename, simplify, remove tests

ff3e9a0
Select commit
Loading
Failed to load commit list.
Merged

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

refactor: Address reviewer feedback — rename, simplify, remove tests
ff3e9a0
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Mar 27, 2026 in 10m 29s

5 issues

code-review: Found 5 issues (2 high, 2 medium, 1 low)

High

Import error: ASYNC_TRANSPORT_ENABLED does not exist, should be ASYNC_TRANSPORT_AVAILABLE - `tests/integrations/asyncio/test_asyncio.py:648`

The test imports ASYNC_TRANSPORT_ENABLED from sentry_sdk.transport, but this variable does not exist. The correct variable name in transport.py is ASYNC_TRANSPORT_AVAILABLE (defined at lines 34-36). This will cause an ImportError when the test runs, preventing it from executing.

Also found at:

  • scripts/populate_tox/tox.jinja:91
Test test_close_with_async_transport_warns will never pass - mocks wrong interface - `tests/test_client.py:1670-1677`

The test mocks sentry_sdk.client.logger.warning and expects it to be called with a specific message. However, the actual close() implementation uses warnings.warn() instead of logger.warning(). Additionally, the expected message ("close() used with AsyncHttpTransport. Prefer close_async() for graceful async shutdown. Performing synchronous best-effort cleanup.") differs from the actual message ("close() used with AsyncHttpTransport. Use close_async() instead."). This test will always fail.

Also found at:

  • tests/test_client.py:1737-1741

Medium

Python closure captures loop variable by reference, not value - `sentry_sdk/worker.py:284`

The lambda lambda t: self._on_task_complete(t, queue_ref) captures queue_ref by reference rather than by value. In Python, closures created in loops capture variables by name, so if multiple tasks are spawned before their callbacks fire, all callbacks will use the most recent queue_ref assignment. This defeats the intended purpose of capturing the queue reference at dispatch time to survive kill()/start() cycles, potentially causing task_done() to be called on the wrong queue.

Async test missing required pytest decorators - `tests/test_transport.py:1058-1060`

The test_async_transport_concurrent_requests function is missing the @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, pytest will not properly execute this as an async test, causing it to appear to pass without actually running the async code. This could lead to false confidence in test coverage.

Low

Unused helper function _make_async_transport_options - `tests/test_transport.py:55-73`

The _make_async_transport_options() helper function is defined but never called anywhere in the test file. This appears to be dead code that adds maintenance burden without providing value. The async tests in this file all construct options inline rather than using this helper.


Duration: 10m 18s · Tokens: 5.2M in / 59.8k out · Cost: $7.80 (+extraction: $0.02, +merge: $0.00, +fix_gate: $0.01)

Annotations

Check failure on line 648 in tests/integrations/asyncio/test_asyncio.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Import error: ASYNC_TRANSPORT_ENABLED does not exist, should be ASYNC_TRANSPORT_AVAILABLE

The test imports `ASYNC_TRANSPORT_ENABLED` from `sentry_sdk.transport`, but this variable does not exist. The correct variable name in `transport.py` is `ASYNC_TRANSPORT_AVAILABLE` (defined at lines 34-36). This will cause an `ImportError` when the test runs, preventing it from executing.

Check failure on line 91 in scripts/populate_tox/tox.jinja

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[ERY-PXL] Import error: ASYNC_TRANSPORT_ENABLED does not exist, should be ASYNC_TRANSPORT_AVAILABLE (additional location)

The test imports `ASYNC_TRANSPORT_ENABLED` from `sentry_sdk.transport`, but this variable does not exist. The correct variable name in `transport.py` is `ASYNC_TRANSPORT_AVAILABLE` (defined at lines 34-36). This will cause an `ImportError` when the test runs, preventing it from executing.

Check failure on line 1677 in tests/test_client.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Test test_close_with_async_transport_warns will never pass - mocks wrong interface

The test mocks `sentry_sdk.client.logger.warning` and expects it to be called with a specific message. However, the actual `close()` implementation uses `warnings.warn()` instead of `logger.warning()`. Additionally, the expected message ("close() used with AsyncHttpTransport. Prefer close_async() for graceful async shutdown. Performing synchronous best-effort cleanup.") differs from the actual message ("close() used with AsyncHttpTransport. Use close_async() instead."). This test will always fail.

Check failure on line 1741 in tests/test_client.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[J5W-M8F] Test test_close_with_async_transport_warns will never pass - mocks wrong interface (additional location)

The test mocks `sentry_sdk.client.logger.warning` and expects it to be called with a specific message. However, the actual `close()` implementation uses `warnings.warn()` instead of `logger.warning()`. Additionally, the expected message ("close() used with AsyncHttpTransport. Prefer close_async() for graceful async shutdown. Performing synchronous best-effort cleanup.") differs from the actual message ("close() used with AsyncHttpTransport. Use close_async() instead."). This test will always fail.

Check warning on line 284 in sentry_sdk/worker.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Python closure captures loop variable by reference, not value

The lambda `lambda t: self._on_task_complete(t, queue_ref)` captures `queue_ref` by reference rather than by value. In Python, closures created in loops capture variables by name, so if multiple tasks are spawned before their callbacks fire, all callbacks will use the most recent `queue_ref` assignment. This defeats the intended purpose of capturing the queue reference at dispatch time to survive `kill()/start()` cycles, potentially causing `task_done()` to be called on the wrong queue.

Check warning on line 1060 in tests/test_transport.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Async test missing required pytest decorators

The `test_async_transport_concurrent_requests` function is missing the `@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`, pytest will not properly execute this as an async test, causing it to appear to pass without actually running the async code. This could lead to false confidence in test coverage.