Skip to content

fix(np): Updates IssueNotificationData, render logic to correctly extract action data#111689

Merged
GabeVillalobos merged 5 commits intomasterfrom
gv/fix-issue-renderer-data
Mar 30, 2026
Merged

fix(np): Updates IssueNotificationData, render logic to correctly extract action data#111689
GabeVillalobos merged 5 commits intomasterfrom
gv/fix-issue-renderer-data

Conversation

@GabeVillalobos
Copy link
Copy Markdown
Member

The initial rendering logic was mostly ok, but had a couple of small bugs which result in data rendering incorrectly for WFE alerts.

This updates the render code, example render data, and even query logic to be closer to our current production alerting.

@GabeVillalobos GabeVillalobos requested a review from a team as a code owner March 26, 2026 22:10
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 26, 2026
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py Outdated
Comment thread src/sentry/notifications/platform/templates/issue.py
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py Outdated
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py Outdated
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py Outdated
Comment thread src/sentry/notifications/platform/templates/issue.py
@github-actions
Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on b340a3a in this run:

tests/sentry/notifications/platform/slack/renderers/test_issue.py::IssueNotificationDataTest::test_from_action_invocationlog
tests/sentry/notifications/platform/slack/renderers/test_issue.py:94: in test_from_action_invocation
    assert result.tags == {"environment", "level"}
E   AttributeError: 'IssueNotificationData' object has no attribute 'tags'
tests/sentry/notifications/platform/slack/renderers/test_issue.py::IssueNotificationDataTest::test_from_action_invocation_empty_tagslog
tests/sentry/notifications/platform/slack/renderers/test_issue.py:111: in test_from_action_invocation_empty_tags
    assert result.tags == set()
E   AttributeError: 'IssueNotificationData' object has no attribute 'tags'
tests/sentry/notifications/platform/slack/renderers/test_issue.py::IssueSlackRendererTest::test_render_produces_blockslog
tests/sentry/notifications/platform/slack/renderers/test_issue.py:265: in test_render_produces_blocks
    assert result == self._build_expected_blocks(
E   assert {'blocks': [{...] test event'} == {'blocks': [{...] test event'}
E     
E     Omitting 1 identical items, use -vv to show
E     Differing items:
E     {'blocks': [{'block_id': '{"issue":19,"rule":18}', 'text': {'text': ':red_circle: <http://testserver/organizations/baz...z/monitors/alerts/18/|Test Detector>    Short ID: BAR-1', 'type': 'mrkdwn'}], 'type': 'context'}, {'type': 'divider'}]} != {'blocks': [{'block_id': '{"issue":19,"rule":18}', 'text': {'text': ':red_circle: <http://testserver/organizations/baz...z/monitors/alerts/18/|Test Detector>    Short ID: BAR-1', 'type': 'mrkdwn'}], 'type': 'context'}, {'type': 'divider'}]}
E     
E     Full diff:
E       {
E           'blocks': [
E               {
E                   'block_id': '{"issue":19,"rule":18}',
E                   'text': {
E                       'text': ':red_circle: '
E     -                 '<http://testserver/organizations/baz/issues/19/?referrer=slack&notification_uuid=test-uuid&workflow_id=18&alert_type=issue|*test '
E     ?                                                                                ----------------------------
E     +                 '<http://testserver/organizations/baz/issues/19/events/93f2343a5fde4a7782ea1540e825f771/?referrer=slack&workflow_id=18&alert_type=issue|*test '
E     ?                                                                 ++++++++++++++++++++++++++++++++++++++++
E                       'event*>',
E                       'type': 'mrkdwn',
E                   },
E                   'type': 'section',
E               },
E               {
E                   'elements': [
E                       {
E                           'text': 'State: *New*   First Seen: *Just now*',
E                           'type': 'mrkdwn',
E                       },
E                   ],
E                   'type': 'context',
E               },
E               {
E                   'elements': [
E                       {
E                           'action_id': 'status::4557861152686080::4557861152686080',
E                           'text': {
E                               'text': 'Resolve',
E                               'type': 'plain_text',
E                           },
E                           'type': 'button',
E                           'value': 'resolved',
E                       },
E                       {
E                           'action_id': 'archive_dialog::4557861152686080::4557861152686080',
E                           'text': {
E                               'text': 'Archive',
E                               'type': 'plain_text',
E                           },
... (34 more lines)
tests/sentry/notifications/platform/slack/renderers/test_issue.py::IssueSlackRendererTest::test_render_with_noteslog
tests/sentry/notifications/platform/slack/renderers/test_issue.py:284: in test_render_with_notes
    assert result == self._build_expected_blocks(
E   assert {'blocks': [{...] test event'} == {'blocks': [{...] test event'}
E     
E     Omitting 1 identical items, use -vv to show
E     Differing items:
E     {'blocks': [{'block_id': '{"issue":25,"rule":24}', 'text': {'text': ':red_circle: <http://testserver/organizations/baz...z/monitors/alerts/24/|Test Detector>    Short ID: BAR-1', 'type': 'mrkdwn'}], 'type': 'context'}, {'type': 'divider'}]} != {'blocks': [{'block_id': '{"issue":25,"rule":24}', 'text': {'text': ':red_circle: <http://testserver/organizations/baz...z/monitors/alerts/24/|Test Detector>    Short ID: BAR-1', 'type': 'mrkdwn'}], 'type': 'context'}, {'type': 'divider'}]}
E     
E     Full diff:
E       {
E           'blocks': [
E               {
E                   'block_id': '{"issue":25,"rule":24}',
E                   'text': {
E                       'text': ':red_circle: '
E     -                 '<http://testserver/organizations/baz/issues/25/?referrer=slack&notification_uuid=test-uuid&workflow_id=24&alert_type=issue|*test '
E     ?                                                                                ----------------------------
E     +                 '<http://testserver/organizations/baz/issues/25/events/150bb3b4c6b54b7a8a791ffb7a31ac92/?referrer=slack&workflow_id=24&alert_type=issue|*test '
E     ?                                                                 ++++++++++++++++++++++++++++++++++++++++
E                       'event*>',
E                       'type': 'mrkdwn',
E                   },
E                   'type': 'section',
E               },
E               {
E                   'elements': [
E                       {
E                           'text': 'State: *New*   First Seen: *Just now*',
E                           'type': 'mrkdwn',
E                       },
E                   ],
E                   'type': 'context',
E               },
E               {
E                   'elements': [
E                       {
E                           'action_id': 'status::4557861152948224::4557861152948224',
E                           'text': {
E                               'text': 'Resolve',
E                               'type': 'plain_text',
E                           },
E                           'type': 'button',
E                           'value': 'resolved',
E                       },
E                       {
E                           'action_id': 'archive_dialog::4557861152948224::4557861152948224',
E                           'text': {
E                               'text': 'Archive',
E                               'type': 'plain_text',
E                           },
... (41 more lines)
tests/sentry/notifications/platform/slack/renderers/test_issue.py::IssueSlackRendererTest::test_render_with_tagslog
tests/sentry/notifications/platform/slack/renderers/test_issue.py:307: in test_render_with_tags
    assert result == self._build_expected_blocks(
E   assert {'blocks': [{...tagged event'} == {'blocks': [{...tagged event'}
E     
E     Omitting 1 identical items, use -vv to show
E     Differing items:
E     {'blocks': [{'block_id': '{"issue":31,"rule":30}', 'text': {'text': ':red_circle: <http://testserver/organizations/baz...z/monitors/alerts/30/|Test Detector>    Short ID: BAR-1', 'type': 'mrkdwn'}], 'type': 'context'}, {'type': 'divider'}]} != {'blocks': [{'block_id': '{"issue":31,"rule":30}', 'text': {'text': ':red_circle: <http://testserver/organizations/baz...z/monitors/alerts/30/|Test Detector>    Short ID: BAR-1', 'type': 'mrkdwn'}], 'type': 'context'}, {'type': 'divider'}]}
E     
E     Full diff:
E       {
E           'blocks': [
E               {
E                   'block_id': '{"issue":31,"rule":30}',
E                   'text': {
E                       'text': ':red_circle: '
E     -                 '<http://testserver/organizations/baz/issues/31/?referrer=slack&notification_uuid=test-uuid&workflow_id=30&alert_type=issue|*tagged '
E     ?                                                                                ----------------------------
E     +                 '<http://testserver/organizations/baz/issues/31/events/fd58d4874c9e465e8ff61890e2593825/?referrer=slack&workflow_id=30&alert_type=issue|*tagged '
E     ?                                                                 ++++++++++++++++++++++++++++++++++++++++
E                       'event*>',
E     -                 'type': 'mrkdwn',
E     -             },
E     -             'type': 'section',
E     -         },
E     -         {
E     -             'block_id': '{"issue":31,"rule":30,"block":"tags"}',
E     -             'text': {
E     -                 'text': 'level: `error`  ',
E                       'type': 'mrkdwn',
E                   },
E                   'type': 'section',
E               },
E               {
E                   'elements': [
E                       {
E                           'text': 'State: *New*   First Seen: *Just now*',
E                           'type': 'mrkdwn',
E                       },
E                   ],
E                   'type': 'context',
E               },
E               {
E                   'elements': [
E                       {
E                           'action_id': 'status::4557861153210368::4557861153275904',
E                           'text': {
E                               'text': 'Resolve',
E                               'type': 'plain_text',
E                           },
E                           'type': 'button',
... (42 more lines)

@GabeVillalobos GabeVillalobos requested a review from a team as a code owner March 26, 2026 23:30
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py Outdated
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py Outdated
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py
Comment thread src/sentry/notifications/platform/slack/renderers/issue.py Outdated
Copy link
Copy Markdown
Contributor

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

group=group,
event=event,
tags=data.tags or None,
tags=set(tag.strip() for tag in tags.split(",")) if tags else None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tag parsing drops empty-string filter from set comprehension

Low Severity

The old tag parsing in the factory used {t.strip() for t in blob.tags.split(",") if t.strip()}, which filtered out empty/whitespace-only entries. The new parsing set(tag.strip() for tag in tags.split(",")) omits the if tag.strip() guard. For inputs with trailing commas or double commas (e.g. "environment,,level" or "environment,"), the resulting set will include an empty string "", which is a minor behavioral regression from the prior code.

Fix in Cursor Fix in Web

@GabeVillalobos GabeVillalobos enabled auto-merge (squash) March 30, 2026 20:42
@GabeVillalobos GabeVillalobos merged commit 64580f1 into master Mar 30, 2026
69 checks passed
@GabeVillalobos GabeVillalobos deleted the gv/fix-issue-renderer-data branch March 30, 2026 21:00
dashed pushed a commit that referenced this pull request Apr 1, 2026
…ract action data (#111689)

The initial rendering logic was mostly ok, but had a couple of small
bugs which result in data rendering incorrectly for WFE alerts.

This updates the render code, example render data, and even query logic
to be closer to our current production alerting.
@github-actions github-actions bot locked and limited conversation to collaborators Apr 15, 2026
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.

2 participants