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

Fix demo alert for inbound email #2081

Merged
merged 9 commits into from
Jun 2, 2023
Merged

Conversation

vstpme
Copy link
Member

@vstpme vstpme commented Jun 1, 2023

What this PR does

Fix HTTP 500 when sending demo alert for inbound integration email.

  • Make all integration configs have consistent is_demo_alert_enabled and example_payload values
  • Add tests

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • CHANGELOG.md updated (or pr:no changelog PR label added if not required)

if payload is None:
payload = self.config.example_payload
if self.is_demo_alert_enabled:
Copy link
Member Author

@vstpme vstpme Jun 1, 2023

Choose a reason for hiding this comment

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

I tried to simplify things a bit and reduce the number of indentation levels.
The only logical change is checking for if not self.is_demo_alert_enabled before anything else.


if not demo_alert_payload:
Copy link
Member Author

Choose a reason for hiding this comment

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

AlertReceiveChannel.send_demo_alert handles payload=None cases

@vstpme vstpme added the pr:no public docs Added to a PR that does not require public documentation updates label Jun 1, 2023
@vstpme vstpme marked this pull request as ready for review June 1, 2023 15:30
@vstpme vstpme requested a review from a team June 1, 2023 15:30
@vstpme vstpme marked this pull request as draft June 1, 2023 15:30
@vstpme vstpme marked this pull request as ready for review June 1, 2023 16:03
Copy link
Contributor

@matiasb matiasb left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@joeyorlando joeyorlando left a comment

Choose a reason for hiding this comment

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

LGTM! You might want to double check this integration file here in the private repo

@@ -102,3 +102,26 @@ def test_default_templates_are_valid():
jinja_template_env.from_string(template)
except TemplateSyntaxError as e:
pytest.fail(e.message)


@pytest.mark.parametrize("config", AlertReceiveChannel._config)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice ✌️

@@ -145,6 +146,21 @@ def test_send_demo_alert_alertmanager_payload_shape(
assert mocked_create_alert.call_args.args[1]["force_route_id"] is None


@mock.patch("apps.integrations.tasks.create_alert.apply_async", return_value=None)
@pytest.mark.parametrize(
"integration", [config.slug for config in AlertReceiveChannel._config if not config.is_demo_alert_enabled]
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@vstpme vstpme enabled auto-merge June 2, 2023 09:42
@vstpme vstpme added this pull request to the merge queue Jun 2, 2023
Merged via the queue into dev with commit 8c8b5e0 Jun 2, 2023
@vstpme vstpme deleted the vadimkerr/fix-demo-alerts-inbound-email branch June 2, 2023 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants