influxdata / influxdata/influxdb
POST checks api: panic happens if `time_since` is not sent
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
discovered in: https://github.com/influxdata/influxdb/issues/21793
to repro, try to create a deadman check with the following request (filling in your own org, token, org id):
```
curl --location --request POST 'https://localhost:8086/api/v2/checks?org=InfluxData' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token mytoken' \
--data-raw '{
"description": "something",
"every": "1m",
"labels": [],
"level": "CRIT",
"name": "something",
"offset": "0s",
"orgID": "38724d454ca19fd7",
"query": {
"builderConfig": {
"buckets": [
"telegraf"
],
"functions": [],
"tags": [
{
"aggregateFunctionType": "filter",
"key": "_measurement",
"values": [
"go_info"
]
},
{
"aggregateFunctionType": "filter",
"key": "_field",
"values": [
"gauge"
]
},
{
"aggregateFunctionType": "filter",
"key": "host",
"values": []
}
]
},
"editMode": "builder",
"hidden": false,
"name": "",
"text": "buckets()"
},
"reportZero": false,
"staleTime": "10m",
"status": "active",
"statusMessageTemplate": "Check: ${ r._check_name } is: ${ r._level }",
"tags": [],
"type": "deadman"
}'
```
results in:
```
{
"code": "internal error",
"message": "a panic has occurred: /api/v2/checks?org=InfluxData: runtime error: invalid memory address or nil pointer dereference"
}
```
making the same request but adding `"timeSince": "90s"` to the request succeeds:
```
curl --location --request POST 'https://localhost:8086/api/v2/checks?org=InfluxData' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token mytoken' \
--data-raw '{
"description": "something",
"every": "1m",
"labels": [],
"level": "CRIT",
"name": "something",
"offset": "0s",
"orgID": "38724d454ca19fd7",
"query": {
"builderConfig": {
"buckets": [
"telegraf"
],
"functions": [],
"tags": [
{
"aggregateFunctionType": "filter",
"key": "_measurement",
"values": [
"go_info"
]
},
{
"aggregateFunctionType": "filter",
"key": "_field",
"values": [
"gauge"
]
},
{
"aggregateFunctionType": "filter",
"key": "host",
"values": []
}
]
},
"editMode": "builder",
"hidden": false,
"name": "",
"text": "buckets()"
},
"reportZero": false,
"staleTime": "10m",
"status": "active",
"statusMessageTemplate": "Check: ${ r._check_name } is: ${ r._level }",
"tags": [],
"type": "deadman",
"timeSince": "90s"
}'
```
Contributor guide
Research direction
Start at the POST /api/v2/checks endpoint and reproduce the deadman-check request from the issue with and without timeSince. Trace how the missing field is handled and add coverage for the request without timeSince; done means it no longer panics and returns an appropriate API response.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100