influxdata / influxdata/influxdb

[BUG] panic while creating check

Open
#21,793 2 comments 0 reactions 0 assignees View on GitHub
area/2.x panic
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Steps to reproduce:__
Using the influx-python library

```python
ChecksService().create_check(post_check=DeadmanCheck(
level=level, every=every, status_message_template="Check: ${ r._check_name } is: ${ r._level }", name=name,
query=self.__create_dashboard_query(query=query, name=name), status=status, description=description, org_id=self.get_organization_id(), offset="0s", labels=[],
report_zero=False, stale_time="10m", tags=[])
```

The Deadman check generates the following payload
```json
{
"created_at":"None",
"description":"hooha",
"every":"10m",
"id":"None",
"labels":[

],
"last_run_error":"None",
"last_run_status":"None",
"latest_completed":"None",
"level":"WARN",
"links":"None",
"name":"test",
"offset":"0s",
"org_id":"c144bc298a525db6",
"owner_id":"None",
"query":{
"builder_config":"None",
"edit_mode":"advanced",
"name":"test",
"text":"from(bucket: \"things\") |> range(start: -7d) |> filter(fn: ""(r) => r._measurement == \"streams\") |> filter(fn: (r) => ""r.identifier == \"mbin_p4\") |> filter(fn: (r) => r._field ""== \"v\") |> filter(fn: (r) => r.mac == \"b827ebc5308a\") "
},
"report_zero":false,
"stale_time":"10m",
"status":"active",
"status_message_template":"Check: ${ r._check_name } is: ${ r._level }",
"tags":[

],
"task_id":"None",
"time_since":"None",
"type":"deadman",
"updated_at":"None"
}
```

__Expected behavior:__
Check should be created

__Actual behavior:__

__Environment info:__

* System info: Linux 5.4.0-66-generic x86_64
* InfluxDB version: InfluxDB 2.0.7 (git: 2a45f0c037) build_date: 2021-06-04T19:17:40Z
* Other relevant environment details: na

__Config:__
Copy any non-default config values here or attach the full config as a gist or file.

__Logs:__
```
ts=2021-07-06T14:00:17.507903Z lvl=error msg="a panic has occurred" log_id=0VB1kwOl000 handler=panic error="/api/v2/checks: runtime error: invalid memory address or nil pointer dereference" stacktrace="goroutine 1705 [running]:\nruntime/debug.Stack(0xc002a06e40, 0xc002acd602, 0x21f87cb)\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x9f\ngithub.com/influxdata/influxdb/v2/http.baseHandler.panic(0x3d78920, 0x34ae098, 0x3dacc40, 0xc002a38e20, 0xc000155900, 0x3983080, 0x4d043c0)\n\t/home/circleci/go/src/github.com/influxdata/influxdb/http/router.go:96 +0x21d\ngithub.com/influxdata/httprouter.(*Router).recv(0xc000628a20, 0x3dacc40, 0xc002a38e20, 0xc000155900)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/httprouter@v1.3.1-0.20191122104820-ee83e2772f69/router.go:361 +0x7b\npanic(0x3983080, 0x4d043c0)\n\t/usr/local/go/src/runtime/panic.go:969 +0x175\ngithub.com/influxdata/flux/ast.(*formatter).formatDurationLiteral(0xc002aac0b0, 0x0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:694 +0x46\ngithub.com/influxdata/flux/ast.(*formatter).formatNode(0xc002aac0b0, 0x3dd8a00, 0x0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:803 +0x43f\ngithub.com/influxdata/flux/ast.(*formatter).formatProperty(0xc002aac0b0, 0xc002adb290)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:601 +0x110\ngithub.com/influxdata/flux/ast.(*formatter).formatNode(0xc002aac0b0, 0x3dd92a0, 0xc002adb290)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:809 +0x25f\ngithub.com/influxdata/flux/ast.(*formatter).formatObjectExpressionBraces(0xc002aac0b0, 0xc002adb320, 0x3dd8e00)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:583 +0x1d7\ngithub.com/influxdata/flux/ast.(*formatter).formatObjectExpressionAsFunctionArgument(0xc002aac0b0, 0xc002adb320)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:545 +0x45\ngithub.com/influxdata/flux/ast.(*f
ormatter).formatCallExpression(0xc002aac0b0, 0xc002adb3b0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:491 +0x16c\ngithub.com/influxdata/flux/ast.(*formatter).formatNode(0xc002aac0b0, 0x3dd8820, 0xc002adb3b0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:757 +0x225\ngithub.com/influxdata/flux/ast.(*formatter).formatProperty(0xc002aac0b0, 0xc002adb680)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:601 +0x110\ngithub.com/influxdata/flux/ast.(*formatter).formatNode(0xc002aac0b0, 0x3dd92a0, 0xc002adb680)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:809 +0x25f\ngithub.com/influxdata/flux/ast.(*formatter).formatObjectExpressionBraces(0xc002aac0b0, 0xc002adb710, 0x3dd8e00)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:583 +0x1d7\ngithub.com/influxdata/flux/ast.(*formatter).formatObjectExpressionAsFunctionArgument(0xc002aac0b0, 0xc002adb710)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:545 +0x45\ngithub.com/influxdata/flux/ast.(*formatter).formatCallExpression(0xc002aac0b0, 0xc002adb7a0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:491 +0x16c\ngithub.com/influxdata/flux/ast.(*formatter).formatNode(0xc002aac0b0, 0x3dd8820, 0xc002adb7a0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:757 +0x225\ngithub.com/influxdata/flux/ast.(*formatter).formatPipeExpression(0xc002aac0b0, 0xc002acfd60)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:506 +0x110\ngithub.com/influxdata/flux/ast.(*formatter).formatNode(0xc002aac0b0, 0x3dd91e0, 0xc002acfd60)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:759 +0x8df\ngithub.com/influxdata/flux/ast.(*formatter).formatPipeExpression(0xc002aac0b0, 0xc002acfdb0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:501 +0x6c\ngithub.com/influxdata/f
lux/ast.(*formatter).formatNode(0xc002aac0b0, 0x3dd91e0, 0xc002acfdb0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:759 +0x8df\ngithub.com/influxdata/flux/ast.(*formatter).formatExpressionStatement(0xc002aac0b0, 0xc002acfe00)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:329 +0x68\ngithub.com/influxdata/flux/ast.(*formatter).formatNode(0xc002aac0b0, 0x3dd8a60, 0xc002acfe00)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:749 +0x7b2\ngithub.com/influxdata/flux/ast.(*formatter).formatFile(0xc002aac0b0, 0xc002a449a0, 0x0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:276 +0x1ce\ngithub.com/influxdata/flux/ast.(*formatter).formatPackage(0xc002aac0b0, 0xc002a3c770)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:234 +0xde\ngithub.com/influxdata/flux/ast.(*formatter).formatNode(0xc002aac0b0, 0x3dd9060, 0xc002a3c770)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:733 +0xb93\ngithub.com/influxdata/flux/ast.Format(0x3dd9060, 0xc002a3c770, 0x4, 0xc002a056b0)\n\t/home/circleci/go/pkg/mod/github.com/influxdata/flux@v0.117.0/ast/format.go:18 +0x66\ngithub.com/influxdata/influxdb/v2/notification/check.Deadman.GenerateFlux(0x7cb06fed598e000, 0xc002a05698, 0x4, 0xc002a056b0, 0x5, 0x73b1d3355a7c000, 0xc144bc298a525db6, 0xc001fb4870, 0xe2, 0xc002a056a0, ...)\n\t/home/circleci/go/src/github.com/influxdata/influxdb/notification/check/deadman.go:40 +0xf6\ngithub.com/influxdata/influxdb/v2/checks.(*Service).createCheckTask(0xc0052cca80, 0x3dc22c0, 0xc002a09950, 0x3deee60, 0xc002a34480, 0xc002a05710, 0x6, 0x3dc22c0, 0xc002a09950, 0x0)\n\t/home/circleci/go/src/github.com/influxdata/influxdb/checks/service.go:339 +0x66\ngithub.com/influxdata/influxdb/v2/checks.(*Service).CreateCheck(0xc0052cca80, 0x3dc22c0, 0xc002a09950, 0x3deee60, 0xc002a34480, 0xc002a05710, 0x6, 0x73b1d3355a7c000, 0x0, 0x0)\n\t/home/circleci/go/src/github.com/influxdata/influxdb
```

__Performance:__
Generate profiles with the following commands for bugs related to performance, locking, out of memory (OOM), etc.

```sh
# Commands should be run when the bug is actively happening.
# Note: This command will run for ~30 seconds.
curl -o profiles.tar.gz "http://localhost:8086/debug/pprof/all?cpu=30s"
iostat -xd 1 30 > iostat.txt
# Attach the `profiles.tar.gz` and `iostat.txt` output files.
```

Contributor guide

Open the contributing guide

Research direction

Start with notification/check/deadman.go:40 and follow the create-check path through checks/service.go:339, using the reported Python payload and stack trace. Inspect the Flux formatter call involved in generating the Deadman check query. Done means creating this check no longer panics and the check is created successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, python
Domain
api, backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
34/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.