Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin crashes on notification #151

Closed
AR1ES opened this issue Mar 5, 2023 · 3 comments · Fixed by #157
Closed

Plugin crashes on notification #151

AR1ES opened this issue Mar 5, 2023 · 3 comments · Fixed by #157

Comments

@AR1ES
Copy link

AR1ES commented Mar 5, 2023

I have Mattermost v7.5.2 bundled with gitlab.
I'm using the AlertManager Plugin v0.4.0.
I configured everything according to Readme.

When I open /plugins/alertmanager/api/webhook I get the text "Mattermost AlertManager Plugin".

But when I send notification like this

POST https://xxxxxx/plugins/alertmanager/api/webhook?token=yyyyyy
Content-type: application/json
{
    "text": "Hello, world."
}

I got an error "500 internal server error'

Server logs:

{"timestamp":"2023-03-05 21:10:34.109 Z","level":"info","msg":"Received alertmanager notification","caller":"app/plugin_api.go:973","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:10:34.114 Z","level":"error","msg":"Plugin failed to ServeHTTP, RPC call failed","caller":"plugin/client_rpc.go:423","plugin_id":"alertmanager","error":"unexpected EOF"}
{"timestamp":"2023-03-05 21:10:34.114 Z","level":"error","msg":"plugin process exited","caller":"plugin/hclog_adapter.go:79","plugin_id":"alertmanager","wrapped_extras":"path/var/opt/gitlab/mattermost/plugins/alertmanager/server/dist/plugin-linux-amd64pid29375errorexit status 2"}

Debug logs:

{"timestamp":"2023-03-05 21:19:55.161 Z","level":"info","msg":"Received alertmanager notification","caller":"app/plugin_api.go:973","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"panic: runtime error: invalid memory address or nil pointer dereference","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xee6fd5]","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"goroutine 27 [running]:","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"main.(*Plugin).handleWebhook(0xc000400900, {0x156b2e0, 0xc000420c60}, 0xc00050e200, {{0x1c8ce20, 0x1}, {0xc0007c84a0, 0x20}, {0xc00011ac78, 0x6}, ...})","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"\tgithub.com/cpanato/mattermost-plugin-alertmanager/server/webhook.go:33 +0x115","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"main.(*Plugin).ServeHTTP(0x7f2da5187f68?, 0x10d68c0?, {0x156b2e0, 0xc000420c60}, 0xc00050e200)","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"\tgithub.com/cpanato/mattermost-plugin-alertmanager/server/plugin.go:131 +0x3d5","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"github.com/mattermost/mattermost-server/v6/plugin.(*hooksRPCServer).ServeHTTP(0xc0004224a0, 0xc0003378a0, 0x1?)","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"\tgithub.com/mattermost/mattermost-server/v6@v6.0.0-20221109191448-21aec2741bfe/plugin/client_rpc.go:453 +0x417","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"reflect.Value.call({0xc0000c1560?, 0xc0000bc868?, 0x13?}, {0x111d53e, 0x4}, {0xc000781ef8, 0x3, 0x3?})","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"\treflect/value.go:584 +0x8c5","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"reflect.Value.Call({0xc0000c1560?, 0xc0000bc868?, 0x0?}, {0xc0000db6f8?, 0x0?, 0x0?})","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"\treflect/value.go:368 +0xbc","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"net/rpc.(*service).call(0xc0000cc340, 0x0?, 0x0?, 0xc0000ce120, 0xc000334b80, 0x0?, {0xf51dc0?, 0xc0003378a0?, 0x0?}, {0xf5eb40, ...}, ...)","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"\tnet/rpc/server.go:382 +0x226","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"created by net/rpc.(*Server).ServeCodec","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.164 Z","level":"debug","msg":"\tnet/rpc/server.go:479 +0x3fe","caller":"plugin/hclog_adapter.go:54","plugin_id":"alertmanager"}
{"timestamp":"2023-03-05 21:19:55.166 Z","level":"error","msg":"Plugin failed to ServeHTTP, RPC call failed","caller":"plugin/client_rpc.go:423","plugin_id":"alertmanager","error":"unexpected EOF"}
{"timestamp":"2023-03-05 21:19:55.166 Z","level":"error","msg":"plugin process exited","caller":"plugin/hclog_adapter.go:79","plugin_id":"alertmanager","wrapped_extras":"path/var/opt/gitlab/mattermost/plugins/alertmanager/server/dist/plugin-linux-amd64pid30003errorexit status 2"}
@cpanato
Copy link
Owner

cpanato commented Mar 13, 2023

Hello, if you curl the endpoint it will return that text. This is expected.
also if you make a post and do not pass the expected payload it will fail but should not panic

@AR1ES
Copy link
Author

AR1ES commented Mar 13, 2023

@cpanato
Thanks for the answer. The request was given as an example. In fact, the problem is observed when receiving messages from AlertManager. Then the plugin crashes.

It turns out that the AlertManager should have some additional settings if its messages are not suitable? In this case, can you tell me what the correct payload should look like so that you can test and make sure that the plugin works correctly?

@cpanato
Copy link
Owner

cpanato commented Mar 13, 2023

@AR1ES the plugin expect the payload that Alertmanager sends to the plugin

you can check a sample config for the alertmanager here https://github.com/cpanato/mattermost-plugin-alertmanager/blob/main/hack/config.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants