influxdata / influxdata/influxdb

NotificationRules - able to create rules with same name

Open
#23,781 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Steps to reproduce:__
List the minimal actions needed to reproduce the behavior.

Working with the API directly...

1. Create an HTTPNotificationEndpoint
2. Create a Check
3. Create a NotificationRule using the endpoint from step 1
4. Reuse the same request used to create the rule in step 3 using the same name and POST it again to `/notificationRules`

__Expected behavior:__
Expected that a second rule using the name of an already existing rule would be rejected. This is the behavior with other resources. A request to create a resource with the same name of an already existing resource of the same type returns HTTP 422.

__Actual behavior:__
A second notificationRule with the same name, and same properties is created. Return status is HTTP 201

__Response from an ensuing GET request__

When sending a GET request to `/notificationRules` to verify that two rules with identical names and other properties have been created the array of notifcation rules confirms the behavior.

```
resp.body {
"notificationRules": [
{
"id": "0a15d00abfa16000",
"name": "HTTPRule_4d05",
"description": "6jpqfuocwolilt52",
"endpointID": "0a15d0096f465000",
"orgID": "736a40f93fa90d37",
"ownerID": "0a15d0080e865000",
"taskID": "0a15d00ac25e9000",
"sleepUntil": "2022-10-05T08:28:34.667Z",
"every": "10m",
"offset": "0s",
"runbookLink": "/api/v2private/notebooks?orgID=9c5955fc99a60b8f",
"statusRules": [
{
"currentLevel": "CRIT",
"previousLevel": "ANY"
}
],
"limit": 3,
"limitEvery": 3600,
"createdAt": "2022-10-05T08:28:34.942380695Z",
"updatedAt": "2022-10-05T08:28:34.942380695Z",
"type": "http",
"labels": [],
"links": {
"self": "/api/v2/notificationRules/0a15d00abfa16000",
"labels": "/api/v2/notificationRules/0a15d00abfa16000/labels",
"members": "/api/v2/notificationRules/0a15d00abfa16000/members",
"owners": "/api/v2/notificationRules/0a15d00abfa16000/owners",
"query": "/api/v2/notificationRules/0a15d00abfa16000/query"
},
"status": "active",
"latestCompleted": "2022-10-05T08:28:34Z",
"latestScheduled": "2022-10-05T08:28:34Z"
},
{
"id": "0a15d00b1aa16000",
"name": "HTTPRule_4d05",
"description": "6jpqfuocwolilt52",
"endpointID": "0a15d0096f465000",
"orgID": "736a40f93fa90d37",
"ownerID": "0a15d0080e865000",
"taskID": "0a15d00b1cde9000",
"sleepUntil": "2022-10-05T08:28:34.667Z",
"every": "10m",
"offset": "0s",
"runbookLink": "/api/v2private/notebooks?orgID=9c5955fc99a60b8f",
"statusRules": [
{
"currentLevel": "CRIT",
"previousLevel": "ANY"
}
],
"limit": 3,
"limitEvery": 3600,
"createdAt": "2022-10-05T08:28:35.30643674Z",
"updatedAt": "2022-10-05T08:28:35.30643674Z",
"type": "http",
"labels": [],
"links": {
"self": "/api/v2/notificationRules/0a15d00b1aa16000",
"labels": "/api/v2/notificationRules/0a15d00b1aa16000/labels",
"members": "/api/v2/notificationRules/0a15d00b1aa16000/members",
"owners": "/api/v2/notificationRules/0a15d00b1aa16000/owners",
"query": "/api/v2/notificationRules/0a15d00b1aa16000/query"
},
"status": "active",
"latestCompleted": "2022-10-05T08:28:35Z",
"latestScheduled": "2022-10-05T08:28:35Z"
}
],
"links": {
"self": "/api/v2/notificationRules?descending=false&limit=20&offset=0&orgID=736a40f93fa90d37"
}
}

```

__Environment info:__

Testing in K8SIDPE remocal.

Latest commit.

```
commit bacd3fe3dadd24c68f0b5c1f1b02877446b1ae26 (HEAD -> master, origin/master, origin/HEAD)
Author: influx-acs[bot] <107396960+influx-acs[bot]@users.noreply.github.com>
Date: Wed Oct 5 07:43:51 2022 +0000
```

Contributor guide

Open the contributing guide

Research direction

Start at the POST /notificationRules endpoint and reproduce the request sequence described in the issue, then inspect the existing duplicate-name behavior for notification rules. Done means a second rule with the same name is rejected with HTTP 422 instead of returning HTTP 201, with coverage for the duplicate request.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.