fix(dedupe): Fall back to a type/args fingerprint for unweakrefable exceptions - #7523
ericapisani wants to merge 7 commits into
Conversation
…xceptions Some exceptions (e.g. built-in types like ValueError) can't be weakly referenced, so DedupeIntegration previously stored the exception object itself, which kept it alive indefinitely and leaked memory. Fall back to a fingerprint of the exception's type and args instead, so duplicate detection still works without retaining a strong reference. Fixes PY-2381 Fixes #6094
There was a problem hiding this comment.
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b24345a. Configure here.
This is the prevent deduplication of exceptions that: - have the same type (e.g. ValueError) - have the exact same arguments (such as the message provided)
reported once per invocation regardless of prior runs. The earlier test failures are because the "event" that would be sent was the client report saying the event was being deduplicated, and so was missing the "context" key.
Codecov Results 📊✅ 65997 passed | ❌ 52 failed | ⏭️ 2999 skipped | Total: 69048 | Pass Rate: 95.58% | Execution Time: 187m 56s 📊 Comparison with Base Branch
➕ New Tests (52)View new tests
❌ Failed Tests
|
| File | Patch % | Lines |
|---|---|---|
| sentry_sdk/integrations/dedupe.py | 70.37% | |
| sentry_sdk/integrations/aws_lambda.py | 50.00% | |
| sentry_sdk/integrations/gcp.py | 50.00% |
Coverage diff
@@ Coverage Diff @@
## master #PR +/-##
==========================================
- Coverage 90.17% 90.03% -0.14%
==========================================
Files 193 179 -14
Lines 25773 20970 -4803
Branches 9532 7534 -1998
==========================================
+ Hits 23241 18880 -4361
- Misses 2532 2090 -442
- Partials 1431 1182 -249Generated by Codecov Action
…roach to fingerprinting" This reverts commit 4919655.

Built-in exceptions like
ValueErrorcan't be weakly referenced, soDedupeIntegrationpreviously stored the exception object itself, which kept it alive indefinitely and leaked memory.These changes create a fingerprint using the following:
tracebackobject if one is available)This ensures that a strong reference in these cases (which it previously was).
For reviewers: there is a reproduction script in the linear issue if you'd like to use it.
Fixes PY-2381
Fixes #6094