Skip to content

Conversation

nora-shap
Copy link
Member

@nora-shap nora-shap commented Aug 16, 2025

Replaces simple "most recent commit" selection with time-based filtering that:

  • Filters out commits that occurred after the issue was first seen (too recent)
  • Filters out commits older than 60 days before the issue occurred (too old)
  • Selects the most recent valid commit within the time window
  • Time window is defined by first_seen on the Issue rather than time of assessment (.now())

@nora-shap nora-shap requested review from a team as code owners August 16, 2025 01:25
Copy link

linear bot commented Aug 16, 2025

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 16, 2025
cursor[bot]

This comment was marked as outdated.

Copy link

codecov bot commented Aug 16, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 13 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/integrations/utils/commit_context.py 45.83% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #97971      +/-   ##
==========================================
- Coverage   81.01%   80.95%   -0.07%     
==========================================
  Files        8555     8567      +12     
  Lines      376380   377848    +1468     
  Branches    24119    24119              
==========================================
+ Hits       304932   305871     +939     
- Misses      71067    71596     +529     
  Partials      381      381              

cursor[bot]

This comment was marked as outdated.

Copy link
Member

@JoshFerge JoshFerge left a comment

Choose a reason for hiding this comment

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

some minor nits, looks good otherwise though!

@@ -96,7 +108,7 @@ def find_commit_context_for_event_all_frames(

_record_commit_context_all_frames_analytics(
selected_blame=selected_blame,
most_recent_blame=most_recent_blame,
most_recent_blame=None,
Copy link
Member Author

@nora-shap nora-shap Aug 26, 2025

Choose a reason for hiding this comment

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

New selection logic no longer keeps track of "most recent" so this metric is lost. Is it worth it to add the logic to track this piece?

Copy link
Member

Choose a reason for hiding this comment

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

why do we need the most recent blame for these analytics?

Copy link
Member Author

Choose a reason for hiding this comment

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

most_recent_blame is used for 1 thing: determining the reason that is added to the metrics, logs, and analytics.

I updated the looping function and analytics logic to account for the shift in functionality, now it can distinguish between commits being too recent, commits being too old, or both

cursor[bot]

This comment was marked as outdated.

Copy link
Member

@JoshFerge JoshFerge left a comment

Choose a reason for hiding this comment

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

makes sense to me, just the question about the analytics

# Select best valid commit
if selected_date < commit_date < group_first_seen:
selected_blame = blame
selected_date = commit_date
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Commit Boundary Logic Excludes Relevant Commits

The commit selection logic in find_commit_context_for_event_all_frames uses strict inequalities, which means commits exactly 60 days old or at the group_first_seen timestamp are incorrectly excluded. This might cause us to miss relevant suspect commits at these boundaries.

Fix in Cursor Fix in Web

@nora-shap nora-shap merged commit e814eda into master Aug 27, 2025
64 checks passed
@nora-shap nora-shap deleted the nora/ID-878 branch August 27, 2025 20:09
Copy link

sentry-io bot commented Aug 28, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

kenzoengineer pushed a commit that referenced this pull request Aug 28, 2025
…mmit detection (#97971)

Replaces simple "most recent commit" selection with time-based filtering
that:
- Filters out commits that occurred after the issue was first seen (too
young)
- Filters out commits older than 60 days before the issue occurred (too
old)
- Processes commits in chronological order and stops early when hitting
age threshold
  - Selects the most recent valid commit within the time window
andrewshie-sentry pushed a commit that referenced this pull request Aug 28, 2025
…mmit detection (#97971)

Replaces simple "most recent commit" selection with time-based filtering
that:
- Filters out commits that occurred after the issue was first seen (too
young)
- Filters out commits older than 60 days before the issue occurred (too
old)
- Processes commits in chronological order and stops early when hitting
age threshold
  - Selects the most recent valid commit within the time window
constantinius pushed a commit that referenced this pull request Sep 1, 2025
…mmit detection (#97971)

Replaces simple "most recent commit" selection with time-based filtering
that:
- Filters out commits that occurred after the issue was first seen (too
young)
- Filters out commits older than 60 days before the issue occurred (too
old)
- Processes commits in chronological order and stops early when hitting
age threshold
  - Selects the most recent valid commit within the time window
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.

2 participants