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

✨ feat(aci): pass legacy rule_id in notification action for links #88282

Merged
merged 4 commits into from
Apr 1, 2025

Conversation

iamrajjoshi
Copy link
Member

in workflow engine, while we are sending notifications:

if we haven't rolled out the new ui, we must build links to the old ui. this means for issue alerts, we need to find the legacy rule_id and build a link using that so that we can build links correctly.

in this pr, i make it so we pass it as part of rule data. in a follow up pr, i will use this field in the many places where we build links to generate the correct link.

@iamrajjoshi iamrajjoshi requested a review from a team March 28, 2025 23:24
@iamrajjoshi iamrajjoshi self-assigned this Mar 28, 2025
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 28, 2025
data={
"actions": [cls.build_rule_action_blob(action, detector.project.organization.id)]
},
data=dict(data),
Copy link
Member Author

Choose a reason for hiding this comment

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

even though RuleData is a TypedDict, mypy was still complaining if i didn't do this

Copy link
Contributor

Choose a reason for hiding this comment

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

do you know what the mypy error was? wonder if it's correctly trying to call something out 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Incompatible type for "data" of "Rule" (got "RuleData", expected "dict[str, Any]") [misc]

Copy link
Member Author

Choose a reason for hiding this comment

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

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 typeddicts can't be downcast to generic dict -- that would allow key stuffing -- here's an example:

class TD(TypedDict):
    x: int
    y: int

def stuffs_keys(d: dict[str, Any]) -> None:
    d['unrelated'] = 1

def takes_td_names(*, x: int, y: int) -> None: ...

def f():
    d: TD = {'x': 1, 'y': 2})
    stuffs_keys(d)  # disallowed!
    takes_td_names(**d)  # would error now!

credit to @asottile-sentry

@iamrajjoshi iamrajjoshi marked this pull request as ready for review March 28, 2025 23:25
@iamrajjoshi iamrajjoshi requested review from a team as code owners March 28, 2025 23:25
Copy link

codecov bot commented Mar 28, 2025

Codecov Report

Attention: Patch coverage is 94.02985% with 4 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/testutils/factories.py 70.00% 3 Missing ⚠️
.../sentry/notifications/notification_action/types.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #88282   +/-   ##
=======================================
  Coverage   87.72%   87.73%           
=======================================
  Files        9991     9994    +3     
  Lines      565802   565784   -18     
  Branches    22253    22247    -6     
=======================================
+ Hits       496358   496388   +30     
+ Misses      69021    68975   -46     
+ Partials      423      421    -2     

@iamrajjoshi iamrajjoshi merged commit 9edc950 into master Apr 1, 2025
48 checks passed
@iamrajjoshi iamrajjoshi deleted the raj/aci/pass-rule-id-issue-alert-registry branch April 1, 2025 23:26
andrewshie-sentry pushed a commit that referenced this pull request Apr 8, 2025
…88282)

in workflow engine, while we are sending notifications:

if we haven't rolled out the new ui, we must build links to the old ui.
this means for issue alerts, we need to find the legacy `rule_id` and
build a link using that so that we can build links correctly.

in this pr, i make it so we pass it as part of rule data. in a follow up
pr, i will use this field in the many places where we build links to
generate the correct link.
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.

3 participants