feat(worker): Enhance flake processing to include passing runs of known flakes#818
feat(worker): Enhance flake processing to include passing runs of known flakes#818sentry[bot] wants to merge 1 commit intomainfrom
Conversation
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.
Reviewed by Cursor Bugbot for commit a67a874. Configure here.
| Q(timestamp__gte=timezone.now() - timedelta(days=1)) & upload_filter | ||
| Q(timestamp__gte=timezone.now() - timedelta(days=1)) | ||
| & upload_filter | ||
| & (FAIL_FILTER | flaky_pass_filter) |
There was a problem hiding this comment.
Query-time filtering misses passes of newly-created flakes
Medium Severity
The flaky_pass_filter uses curr_flakes.keys() at query-build time, so passing testruns for tests that become flaky during the same upload's processing are excluded from the results. Previously, the filtering happened in the loop body (if test_id not in curr_flakes: continue), which saw curr_flakes after mutations from earlier iterations—correctly capturing passes that follow a failure for the same test within one upload. This regression causes inaccurate recent_passes_count and count on newly-created flakes when a test both fails and passes in the same upload (e.g. retries).
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a67a874. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #818 +/- ##
==========================================
- Coverage 92.25% 92.25% -0.01%
==========================================
Files 1306 1306
Lines 48004 48006 +2
Branches 1636 1636
==========================================
Hits 44286 44286
- Misses 3407 3409 +2
Partials 311 311
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |


Fixes WORKER-Y7Q. The issue was that: The
process_flakes_for_commitfunction executes N queries to fetch all testruns per upload, exacerbated by fetching excessive unfiltered data.FAIL_FILTERconstant to consolidate failure outcome checks.get_testrunsto acceptcurr_flakesto identify currently flaky tests.get_testrunsto filter for test runs that are either failures (failure, flaky_fail, error) or passing runs of tests currently identified as flaky.This fix was generated by Seer in Sentry, triggered automatically. 👁️ Run ID: 13335820
Not quite right? Click here to continue debugging with Seer.
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
Note
Medium Risk
Changes the query/filtering used to select
Testrunrecords for flake processing, which can alter flake detection outcomes and has potential performance implications depending on the size ofcurr_flakes. Scope is limited to the worker’s test analytics flake pipeline.Overview
Flake processing now fetches only recent
Testruns that are either failures (failure/flaky_fail/error) or passes for tests already known to be flaky, so pass events can advance flake expiration and reduce over-fetching.This introduces a shared
FAIL_FILTERand updatesget_testruns/process_single_uploadto acceptcurr_flakesand apply the new combined filter.Reviewed by Cursor Bugbot for commit a67a874. Bugbot is set up for automated code reviews on this repo. Configure here.