Skip to content

feat(worker): Enhance flake processing to include passing runs of known flakes#818

Open
sentry[bot] wants to merge 1 commit intomainfrom
seer/feat/worker-flake-pass-processing
Open

feat(worker): Enhance flake processing to include passing runs of known flakes#818
sentry[bot] wants to merge 1 commit intomainfrom
seer/feat/worker-flake-pass-processing

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry bot commented Apr 15, 2026

Fixes WORKER-Y7Q. The issue was that: The process_flakes_for_commit function executes N queries to fetch all testruns per upload, exacerbated by fetching excessive unfiltered data.

  • Introduced a FAIL_FILTER constant to consolidate failure outcome checks.
  • Modified get_testruns to accept curr_flakes to identify currently flaky tests.
  • Updated get_testruns to filter for test runs that are either failures (failure, flaky_fail, error) or passing runs of tests currently identified as flaky.
  • This ensures that successful executions of known flaky tests are also considered during flake analysis.

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 Testrun records for flake processing, which can alter flake detection outcomes and has potential performance implications depending on the size of curr_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_FILTER and updates get_testruns/process_single_upload to accept curr_flakes and 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.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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

Fix All in Cursor

❌ 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a67a874. Configure here.

@sentry
Copy link
Copy Markdown
Contributor Author

sentry bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.25%. Comparing base (8c332b1) to head (a67a874).
✅ All tests successful. No failed tests found.

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              
Flag Coverage Δ
workerintegration 58.58% <50.00%> (-0.01%) ⬇️
workerunit 90.37% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link
Copy Markdown

codecov-notifications bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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.

0 participants