Skip to content

fix(grouping): Fix buggy chained exception filtering #93966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 23, 2025

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Jun 20, 2025

This fixes two bugs with the way we handle chained exceptions when grouping. In the first case, we assume that there will always be a root exception (an exception with exception_id = 0). In the second, we assume that an exception will never be listed as its own parent. Both of those are reasonable assumptions to make about a well-formed tree, but for some reason, sometimes the data we get doesn't work that way, and we end up hitting an error.

Though we handle that error gracefully, it would be better if we didn't error out at all. To fix this, this PR checks for those cases explicitly and handles them directly, before they can cause an error.

The effects of this change can be seen in two places in the tests: We no longer have to exclude certain test cases from our check that no exception has been logged, and one test case which previously was having one of its exceptions wrongly excluded from grouping now includes the full chain.

Fixes #73592
Fixes https://sentry.my.sentry.io/organizations/sentry/issues/2293485
Fixes https://sentry.sentry.io/issues/6634847839
Fixes https://sentry.my.sentry.io/organizations/sentry/issues/2293421

This comment was marked as resolved.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 20, 2025
Copy link

codecov bot commented Jun 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #93966      +/-   ##
==========================================
- Coverage   88.04%   88.03%   -0.01%     
==========================================
  Files       10356    10356              
  Lines      598264   598266       +2     
  Branches    23232    23232              
==========================================
- Hits       526720   526709      -11     
- Misses      71076    71089      +13     
  Partials      468      468              

@lobsterkatie lobsterkatie force-pushed the kmclb-small-grouping-test-changes-june-2025 branch from d12d4f7 to 95486b2 Compare June 20, 2025 18:55
@lobsterkatie lobsterkatie force-pushed the kmclb-fix-exception-group-filtering-errors branch from 593afd8 to c9e82ee Compare June 20, 2025 18:55
@lobsterkatie lobsterkatie marked this pull request as ready for review June 20, 2025 20:20
@lobsterkatie lobsterkatie requested a review from a team as a code owner June 20, 2025 20:20
Base automatically changed from kmclb-small-grouping-test-changes-june-2025 to master June 20, 2025 20:40
Copy link
Member

@yuvmen yuvmen left a comment

Choose a reason for hiding this comment

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

Looks good, a question and a minor suggestion you can freely ignore

if (
mechanism
and mechanism.exception_id is not None
and mechanism.exception_id != mechanism.parent_id
Copy link
Member

Choose a reason for hiding this comment

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

minor - The analytical part of my brain is thinking that the ids_seen thing is basically detecting circles, so why are we treating circles of 2 different than circles of more than that, so we probably have a way to do this without explicitly checking the mechanism.parent_id, and simply detecting that we already saw this ID.
But there is something to be said about clarity, and for putting out there in a more forward manner that this is something that is possible and we detect for, so if you feel like keeping it like this thats totally fine too.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a valid point, but I like the clarity, and also, just relying on ids_seen wouldn't catch the case where there's only one exception, but it's listed as its own parent.

I suppose we could replace this check with checking if the parent is in ids_seen as well, but then we still have the same number of checks and IMHO it'd be less clear what problem we're trying to solve.

@@ -1,5 +1,5 @@
---
created: '2025-06-18T22:47:54.553430+00:00'
created: '2025-06-20T17:24:14.091297+00:00'
Copy link
Member

Choose a reason for hiding this comment

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

just asking, you have more context here - in terms of testing I am just wondering how isolated is the impact of this change, is it just how we group, or are we possibly letting through errors with a structure we didnt let through before, and we need to make sure our system can handle such errors? Its totally possible these errors always went through we just grouped them wrong and so theres less to worry about

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the only thing this whole parent/child setup affects is the hash calculation and how we lay the errors out on the page in issue details. So this will indeed change the hash value for events like this, but it'll change them to what they should have been all along. (And this isn't a super common case, so the impact in terms of noise should hopefully be pretty minimal.)

@lobsterkatie lobsterkatie merged commit 038e308 into master Jun 23, 2025
64 checks passed
@lobsterkatie lobsterkatie deleted the kmclb-fix-exception-group-filtering-errors branch June 23, 2025 20:33
@github-actions github-actions bot locked and limited conversation to collaborators Jul 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[grouping] Buggy edge cases in filter_exceptions_for_exception_groups - no/empty exception 0
2 participants