Skip to content

fix(statistical-detectors): Add tiebreaker to TrendBundle heap comparison - #128479

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/trendbundle-heap-tiebreaker
Open

sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/trendbundle-heap-tiebreaker

Conversation

@sentry

@sentry sentry Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Problem

In limit_regressions_by_project, TrendBundle objects are pushed into a heap as (bundle.score, bundle) tuples. When two bundles have identical scores, heapq compares the second element (TrendBundle) directly. Because TrendBundle is a frozen dataclass with no __lt__ defined, this raises a TypeError: '<' not supported between instances of 'TrendBundle' and 'TrendBundle'.

Fix

  • Add a monotonically increasing counter (itertools.count()) as a tiebreaker in the heap tuple: (bundle.score, next(counter), bundle).
  • Update the unpacking loop in limit_regressions_by_project.
  • Add a regression test with equal scores in test_statistical_detectors.py.

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. and is gonna need some rights from me in order to utilize my contributions in this here 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.

Fixes SENTRY-5WVH

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@sentry
sentry Bot requested review from a team as code owners October 21, 2026 23:12
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants