mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 16:14:02 +00:00
newrelic: ids are uuids, not integers.
The previous fixtures were not generated from New Relic directly, so incorrectly implied that `id` was an integer. See the examples for `issueId` in their documentation[^1]. [^1]: https://docs.newrelic.com/docs/alerts-applied-intelligence/notifications/message-templates/
This commit is contained in:
committed by
Tim Abbott
parent
b7059807ac
commit
e37a734bd7
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
||||||
"id": 1234,
|
"id": "3576f543-dc3c-4d97-9f16-5c81f35195cb",
|
||||||
"details": "Violation description test.",
|
"details": "Violation description test.",
|
||||||
"alertPolicyNames": ["Test policy name"],
|
"alertPolicyNames": ["Test policy name"],
|
||||||
"condition_name": "Server Down",
|
"condition_name": "Server Down",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
||||||
"id": 1234,
|
"id": "8ceed342-f305-4bfa-adb8-97ba93f5dd26",
|
||||||
"details": "Violation description test.",
|
"details": "Violation description test.",
|
||||||
"alertPolicyNames": ["Test policy name"],
|
"alertPolicyNames": ["Test policy name"],
|
||||||
"condition_name": "Server Down",
|
"condition_name": "Server Down",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
||||||
"id": 1234,
|
"id": "f0d98b28-bf9d-49e7-b9d0-ac7cbb52e73a",
|
||||||
"details": "Violation description test.",
|
"details": "Violation description test.",
|
||||||
"alertPolicyNames": ["Test policy name"],
|
"alertPolicyNames": ["Test policy name"],
|
||||||
"condition_name": "Server Down",
|
"condition_name": "Server Down",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
||||||
"id": 1234,
|
"id": "8114ada3-572e-4550-a310-12375371669e",
|
||||||
"details": "Violation description test.",
|
"details": "Violation description test.",
|
||||||
"alertPolicyNames": ["Test policy name"],
|
"alertPolicyNames": ["Test policy name"],
|
||||||
"condition_name": "Server Down",
|
"condition_name": "Server Down",
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"id": 1234,
|
"id": "e04156e4-4cac-4f39-9d27-75d361e40a6d",
|
||||||
"createdAt": 1605133931151,
|
"createdAt": 1605133931151,
|
||||||
"state": "activated"
|
"state": "activated"
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
||||||
"id": 1234,
|
"id": "3881eb6c-6d57-447e-beaf-b2f610f014b0",
|
||||||
"details": "Violation description test.",
|
"details": "Violation description test.",
|
||||||
"alertPolicyNames": ["Test policy name"],
|
"alertPolicyNames": ["Test policy name"],
|
||||||
"condition_name": "Server Down",
|
"condition_name": "Server Down",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
||||||
"id": 1234,
|
"id": "279751d5-8ad8-41d4-adb8-9e895c58b606",
|
||||||
"details": "Violation description test.",
|
"details": "Violation description test.",
|
||||||
"alertPolicyNames": ["Test policy name"],
|
"alertPolicyNames": ["Test policy name"],
|
||||||
"condition_name": "Server Down",
|
"condition_name": "Server Down",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
||||||
"id": 1234,
|
"id": "6eba9b54-898f-43eb-8892-e41ddca4a10f",
|
||||||
"details": "Violation description test.",
|
"details": "Violation description test.",
|
||||||
"alertPolicyNames": ["Test policy name"],
|
"alertPolicyNames": ["Test policy name"],
|
||||||
"condition_name": "Server Down",
|
"condition_name": "Server Down",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
||||||
"id": 1234,
|
"id": "1d1fff5c-c723-4bf6-8458-bc63b253279e",
|
||||||
"details": "Violation description test.",
|
"details": "Violation description test.",
|
||||||
"alertPolicyNames": ["Test policy name"],
|
"alertPolicyNames": ["Test policy name"],
|
||||||
"condition_name": "Server Down",
|
"condition_name": "Server Down",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
"incident_acknowledge_url": "https://alerts.newrelic.com/accounts/2941966/incidents/1234/acknowledge",
|
||||||
"id": 1234,
|
"id": "37d07862-e156-480f-86f9-7e8e9b7ed4f4",
|
||||||
"details": "Violation description test.",
|
"details": "Violation description test.",
|
||||||
"alertPolicyNames": ["Test policy name"],
|
"alertPolicyNames": ["Test policy name"],
|
||||||
"condition_name": "Server Down",
|
"condition_name": "Server Down",
|
||||||
|
@@ -131,7 +131,7 @@ No details.
|
|||||||
# corresponding json fixtures have "_new" trailing in the name
|
# corresponding json fixtures have "_new" trailing in the name
|
||||||
|
|
||||||
def test_activated_new(self) -> None:
|
def test_activated_new(self) -> None:
|
||||||
expected_topic = "Test policy name (1234)"
|
expected_topic = "Test policy name (8ceed342-f305-4bfa-adb8-97ba93f5dd26)"
|
||||||
expected_message = """
|
expected_message = """
|
||||||
[Incident](https://alerts.newrelic.com/accounts/2941966/incidents/1234) **active** for condition: **Server Down** at <time:2020-11-11 22:32:11.151000+00:00>
|
[Incident](https://alerts.newrelic.com/accounts/2941966/incidents/1234) **active** for condition: **Server Down** at <time:2020-11-11 22:32:11.151000+00:00>
|
||||||
``` quote
|
``` quote
|
||||||
@@ -147,7 +147,7 @@ Violation description test.
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_created_new(self) -> None:
|
def test_created_new(self) -> None:
|
||||||
expected_topic = "Test policy name (1234)"
|
expected_topic = "Test policy name (8114ada3-572e-4550-a310-12375371669e)"
|
||||||
expected_message = """
|
expected_message = """
|
||||||
[Incident](https://alerts.newrelic.com/accounts/2941966/incidents/1234) **created** for condition: **Server Down**
|
[Incident](https://alerts.newrelic.com/accounts/2941966/incidents/1234) **created** for condition: **Server Down**
|
||||||
""".strip()
|
""".strip()
|
||||||
@@ -160,7 +160,7 @@ Violation description test.
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_closed_new(self) -> None:
|
def test_closed_new(self) -> None:
|
||||||
expected_topic = "Test policy name (1234)"
|
expected_topic = "Test policy name (f0d98b28-bf9d-49e7-b9d0-ac7cbb52e73a)"
|
||||||
expected_message = """
|
expected_message = """
|
||||||
[Incident](https://alerts.newrelic.com/accounts/2941966/incidents/1234) **closed** for condition: **Server Down**
|
[Incident](https://alerts.newrelic.com/accounts/2941966/incidents/1234) **closed** for condition: **Server Down**
|
||||||
""".strip()
|
""".strip()
|
||||||
@@ -173,7 +173,7 @@ Violation description test.
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_acknowledged_new(self) -> None:
|
def test_acknowledged_new(self) -> None:
|
||||||
expected_topic = "Test policy name (1234)"
|
expected_topic = "Test policy name (3576f543-dc3c-4d97-9f16-5c81f35195cb)"
|
||||||
expected_message = """
|
expected_message = """
|
||||||
[Incident](https://alerts.newrelic.com/accounts/2941966/incidents/1234) **acknowledged** by **Alice** for condition: **Server Down**
|
[Incident](https://alerts.newrelic.com/accounts/2941966/incidents/1234) **acknowledged** by **Alice** for condition: **Server Down**
|
||||||
""".strip()
|
""".strip()
|
||||||
@@ -199,7 +199,7 @@ Violation description test.
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_missing_fields_new(self) -> None:
|
def test_missing_fields_new(self) -> None:
|
||||||
expected_topic = "Unknown Policy (1234)"
|
expected_topic = "Unknown Policy (e04156e4-4cac-4f39-9d27-75d361e40a6d)"
|
||||||
expected_message = """
|
expected_message = """
|
||||||
[Incident](https://alerts.newrelic.com) **active** for condition: **Unknown condition** at <time:2020-11-11 22:32:11.151000+00:00>
|
[Incident](https://alerts.newrelic.com) **active** for condition: **Unknown condition** at <time:2020-11-11 22:32:11.151000+00:00>
|
||||||
``` quote
|
``` quote
|
||||||
|
@@ -12,6 +12,7 @@ from zerver.lib.validator import (
|
|||||||
check_list,
|
check_list,
|
||||||
check_none_or,
|
check_none_or,
|
||||||
check_string,
|
check_string,
|
||||||
|
check_string_fixed_length,
|
||||||
check_union,
|
check_union,
|
||||||
to_wild_value,
|
to_wild_value,
|
||||||
)
|
)
|
||||||
@@ -59,7 +60,7 @@ def api_newrelic_webhook(
|
|||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
# Handle old format
|
# Handle old format
|
||||||
# Once old is EOLed, delete if block and keep else block
|
# Once old is EOLed, delete if block and keep else block
|
||||||
if not payload.get("id").tame(check_none_or(check_int)):
|
if not payload.get("id").tame(check_none_or(check_string_fixed_length(36))):
|
||||||
info = {
|
info = {
|
||||||
"condition_name": payload.get("condition_name", "Unknown condition").tame(check_string),
|
"condition_name": payload.get("condition_name", "Unknown condition").tame(check_string),
|
||||||
"details": payload.get("details", "No details.").tame(check_string),
|
"details": payload.get("details", "No details.").tame(check_string),
|
||||||
@@ -160,9 +161,7 @@ def api_newrelic_webhook(
|
|||||||
policy_names_str = "Unknown Policy"
|
policy_names_str = "Unknown Policy"
|
||||||
topic_info = {
|
topic_info = {
|
||||||
"policy_name": policy_names_str,
|
"policy_name": policy_names_str,
|
||||||
"incident_id": payload.get("id", "Unknown ID").tame(
|
"incident_id": payload.get("id", "Unknown ID").tame(check_string),
|
||||||
check_union([check_string, check_int])
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
topic = TOPIC_TEMPLATE.format(**topic_info)
|
topic = TOPIC_TEMPLATE.format(**topic_info)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user