influxdata / influxdata/influxdb
InfluxDB 2.x Swagger: POST 'notificationRules` does not require `tagRules` key but DOES require `every` key
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
@stephanie-engel commented on [Fri Aug 07 2020](https://github.com/influxdata/idpe/issues/8149)
**Description:**
When referencing the [swagger spec](https://github.com/influxdata/influxdb/blob/d83fae37f6a18b61c854ec01a8a55c4c47b0f121/http/swagger.yml#L5867) for `notificationRules`, the POST method:
- does actually require the `tagRules` key (even though the spec indicates that the key _is_ required)
- the `every` key is required (but that is not indicated in the spec)
**Steps:**
In an Cloud2 instance:
`tagRules` is present, but `every` is missing:
```
curl --location --request POST 'http://gateway-main.se-cluster.svc.cluster.local:9999/api/v2/notificationRules' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token myToken' \
--data-raw '{
"type":"http",
"orgID":"0608b4ea5df7d000",
"name":"postman created nr",
"status":"active",
"endpointID":"061a95ab0255b000",
"tagRules":[],
"statusRules":[{"currentLevel":"INFO","period":"1h","count":1}]
}'
```
Returns a 500 error
```
{"code":"internal error","message":"unknown internal transaction error"}
```
but when `every` is added :
```
curl --location --request POST 'http://gateway-main.se-cluster.svc.cluster.local:9999/api/v2/notificationRules' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token myToken' \
--data-raw '{
"type":"http",
"orgID":"0608b4ea5df7d000",
"name":"postman created nr",
"status":"active",
"endpointID":"061a95ab0255b000",
"tagRules":[],
"statusRules":[{"currentLevel":"INFO","period":"1h","count":1}],
"every":"10m"
}'
```
Response is 201 Created
```
{"id":"061e918cc595b000","name":"postman created nr","endpointID":"061a95ab0255b000","orgID":"0608b4ea5df7d000","ownerID":"0608b4ea4af7d000","every":"10m","runbookLink":"","statusRules":[{"currentLevel":"INFO","previousLevel":null}],"createdAt":"2020-08-07T18:57:16.054784724Z","updatedAt":"2020-08-07T18:57:16.054784724Z","type":"http","labels":[],"links":{"self":"/api/v2/notificationRules/061e918cc595b000","labels":"/api/v2/notificationRules/061e918cc595b000/labels","members":"/api/v2/notificationRules/061e918cc595b000/members","owners":"/api/v2/notificationRules/061e918cc595b000/owners","query":"/api/v2/notificationRules/061e918cc595b000/query"},"status":"active","latestCompleted":"2020-08-07T18:57:16Z","latestScheduled":"2020-08-07T18:57:16Z"}
```
Also `tagRules` can be removed altogether and the POST still returns a success:
```
curl --location --request POST 'http://gateway-main.se-cluster.svc.cluster.local:9999/api/v2/notificationRules' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token myToken' \
--data-raw '{
"type":"http",
"orgID":"0608b4ea5df7d000",
"name":"postman created nr",
"status":"active",
"endpointID":"061a95ab0255b000",
"statusRules":[{"currentLevel":"INFO","period":"1h","count":1}],
"every":"10m"
}'
```
```
{"id":"061e91f37595b000","name":"postman created nr","endpointID":"061a95ab0255b000","orgID":"0608b4ea5df7d000","ownerID":"0608b4ea4af7d000","every":"10m","runbookLink":"","statusRules":[{"currentLevel":"INFO","previousLevel":null}],"createdAt":"2020-08-07T18:59:01.206301162Z","updatedAt":"2020-08-07T18:59:01.206301162Z","type":"http","labels":[],"links":{"self":"/api/v2/notificationRules/061e91f37595b000","labels":"/api/v2/notificationRules/061e91f37595b000/labels","members":"/api/v2/notificationRules/061e91f37595b000/members","owners":"/api/v2/notificationRules/061e91f37595b000/owners","query":"/api/v2/notificationRules/061e91f37595b000/query"},"status":"active","latestCompleted":"2020-08-07T18:59:01Z","latestScheduled":"2020-08-07T18:59:01Z"}
```
---
@stephanie-engel commented on [Fri Aug 07 2020](https://github.com/influxdata/idpe/issues/8149#issuecomment-670664948)
This is happening in both OSS and Cloud 2
Contributor guide
Research direction
Start with the notificationRules POST definition in http/swagger.yml at the linked specification location and compare its required fields with the request examples in this issue. Update the specification so tagRules and every reflect the observed API behavior, then verify the documented request and response requirements are consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100