Skip to content
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

ref(alerts): use registry pattern for EventAttributeCondition attempt 2 #79456

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

cathteng
Copy link
Member

I removed a KeyError check when I merged the first time in #79435. Putting it back should allow this to deploy now. Added tests that fail without the check.

@cathteng cathteng requested review from a team October 21, 2024 21:14
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 21, 2024
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 75.26882% with 46 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/rules/conditions/event_attribute.py 75.26% 23 Missing and 23 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #79456      +/-   ##
==========================================
+ Coverage   78.31%   78.32%   +0.01%     
==========================================
  Files        7137     7137              
  Lines      315317   315391      +74     
  Branches    51529    51545      +16     
==========================================
+ Hits       246942   247036      +94     
+ Misses      61899    61886      -13     
+ Partials     6476     6469       -7     

else:
try:
attribute_values = attr_handler.handle(path, event)
except KeyError:
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉 nice that this refactor separates this error handling vs before - it's a lot simpler to reason about the key error.

for extra credit, i think it might be even nicer for us to update the AttributeHandler implementations so each individual handler works as intended (either returning [] or the correct value)

Copy link
Member Author

Choose a reason for hiding this comment

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

i'll add that and still have the KeyError, but capture the exception since we know it actually shouldn't happen

@@ -365,6 +375,24 @@ def test_error_handled_not_defined(self):
)
self.assertDoesNotPass(rule, event)

@patch("sentry.eventstore.models.get_interfaces", return_value={})
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for adding more test cases to cover this.

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