Skip to content

fix(aci): fix rule serializer lastTriggered to account for WorkflowFireHistory #95939

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 4 commits into from
Jul 21, 2025

Conversation

cathteng
Copy link
Member

After we enable single processing, the last triggered field for the Rule in the serializer should also account for WorkflowFireHistory.

@cathteng cathteng requested a review from a team as a code owner July 18, 2025 21:37
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 18, 2025
cursor[bot]

This comment was marked as outdated.

@cathteng cathteng requested a review from a team July 18, 2025 21:55
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Member

@iamrajjoshi iamrajjoshi left a comment

Choose a reason for hiding this comment

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

smort

Copy link

codecov bot commented Jul 18, 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   #95939       +/-   ##
===========================================
+ Coverage   38.50%   87.78%   +49.27%     
===========================================
  Files        9955    10585      +630     
  Lines      557639   610023    +52384     
  Branches    23982    23982               
===========================================
+ Hits       214738   535520   +320782     
+ Misses     342617    74219   -268398     
  Partials      284      284               

@cathteng
Copy link
Member Author

@iamrajjoshi cursor concern is legit so gonna fix it up before merge

Copy link

@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.

Bug: Missing Keys in Lookup Cause Errors

A KeyError occurs when attempting to update last_triggered_lookup with WorkflowFireHistory data. The last_triggered_lookup dictionary is initially populated only with RuleFireHistory entries. If a rule has WorkflowFireHistory but no RuleFireHistory, its rule_id will be missing from last_triggered_lookup, causing a KeyError during direct access. Additionally, if existing_date is None, the comparison new_date > existing_date would result in a TypeError.

src/sentry/api/serializers/models/rule.py#L235-L239

# Take the maximum date between RuleFireHistory and WorkflowFireHistory
existing_date = last_triggered_lookup[rule_id]
new_date = wfh["date_added"]
if new_date > existing_date:
last_triggered_lookup[rule_id] = new_date

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@cathteng cathteng merged commit a620103 into master Jul 21, 2025
65 checks passed
@cathteng cathteng deleted the cathy/aci/fix-serializer-rule-triggered branch July 21, 2025 16:30
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