FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: Mock attributes in redis cluster tests by sentrivana · Pull Request #7022 · getsentry/sentry-python · GitHub

test: Mock attributes in redis cluster tests - #7022

Merged
sentrivana merged 3 commits into
masterfrom
ivana/fix-redis
Aug 4, 2026
Merged

test: Mock attributes in redis cluster tests#7022
sentrivana merged 3 commits into
masterfrom
ivana/fix-redis

Conversation

sentrivana commented Aug 4, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Description

Redis started accessing an internal attribute on the Pipeline class, which threw an AttributeError in our tests since we were not mocking the class fully.

Also, set up pytest-asyncio in Python 3.14 so that we can run async tests.

Issues

Closes #6974

Reminders

sentrivana marked this pull request as ready for review August 4, 2026 06:23
sentrivana requested a review from a team as a code owner August 4, 2026 06:23

cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Cursor Bugbot has reviewed your changes and found 1 potential issue.

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 54ca4d2. Configure here.

Comment thread scripts/populate_tox/config.py Outdated
sentrivana enabled auto-merge (squash) August 4, 2026 06:25
sentrivana disabled auto-merge August 4, 2026 06:25
sentrivana enabled auto-merge (squash) August 4, 2026 06:27
redis.RedisCluster.pipeline = lambda *_, **__: pipeline_cls(
MagicMock(), MagicMock()
)
redis.RedisCluster.get_default_node = lambda *_, **__: redis.cluster.ClusterNode(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Bug: The sync Redis ClusterPipeline integration passes the pipeline instance to _set_cluster_db_data instead of the cluster client, causing a silently-suppressed AttributeError and missing span data.
Severity: MEDIUM

Suggested Fix

Create a new wrapper function for the sync case, similar to _set_async_cluster_pipeline_db_data. This function should extract the RedisCluster client from the ClusterPipeline instance and then pass the client to _set_cluster_db_data. Update the patch_redis_pipeline call for cluster.ClusterPipeline to use this new wrapper function as its set_db_data_fn.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: tests/integrations/redis/cluster/test_redis_cluster.py#L22

Potential issue: In the synchronous Redis cluster pipeline integration, the
`patch_redis_pipeline` function incorrectly passes the `ClusterPipeline` instance itself
to the `_set_cluster_db_data` function. This function expects a `RedisCluster` instance
to fetch connection details. When it calls `get_default_node()` on the pipeline object,
an `AttributeError` occurs. This error is silently caught by
`capture_internal_exceptions()`, resulting in the failure to add database connection
metadata (host, port) to the corresponding APM spans. This issue does not occur in the
async implementation, which correctly extracts the client from the pipeline before
gathering data.

Did we get this right? 👍 / 👎 to inform future reviews.

sentrivana merged commit 52a7c26 into master Aug 4, 2026
145 checks passed
sentrivana deleted the ivana/fix-redis branch August 4, 2026 06:41

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

95086 passed | ⏭️ 6239 skipped | Total: 101325 | Pass Rate: 93.84% | Execution Time: 343m 52s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests 📈 +104
Failed Tests
Skipped Tests 📉 -104

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2513 uncovered lines.
✅ Project coverage is 89.88%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.88%    89.88%        —%
==========================================
  Files          193       193         —
  Lines        24834     24834         —
  Branches      8912      8912         —
==========================================
+ Hits         22321     22321         —
- Misses        2513      2513         —
- Partials      1417      1417         —

Generated by Codecov Action

mgaligniana pushed a commit to mgaligniana/sentry-python that referenced this pull request Aug 9, 2026
### Description
Redis started accessing an internal attribute on the Pipeline class,
which threw an `AttributeError` in our tests since we were not mocking
the class fully.

Also, set up `pytest-asyncio` in Python 3.14 so that we can run async
tests.

#### Issues
Closes getsentry#6974

#### Reminders
- Please add tests to validate your changes, and lint your code using
`uv run ruff`.
- Add GH Issue ID _&_ Linear ID (if applicable)
- PR title should use [conventional
commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type)
style (`feat:`, `fix:`, `ref:`, `meta:`)
- For external contributors:
[CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md),
[Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord
community](https://discord.gg/Ww9hbqr)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Fix Redis tox failures

2 participants


Back | FazBrowse Home | New Git URL