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

prometheus_bot fails with panic with newly created bot #11

Open
rutsky opened this issue Mar 7, 2017 · 8 comments
Open

prometheus_bot fails with panic with newly created bot #11

rutsky opened this issue Mar 7, 2017 · 8 comments
Assignees

Comments

@rutsky
Copy link
Contributor

rutsky commented Mar 7, 2017

I'm trying prometheus_bot from master branch (271ff17) compiled with Go 1.6.2 from Ubuntu 16.04 64-bit and have observed panic during handling of first requests with newly created Telegram bot.

I can't reproduce this issue currently and I believe the issue is related to freshly created Telegram bot or some issue on Telegram side.
I want to leave this issue here for the reference, in case anyone else will observe it later.

Here is what I've done.

  1. Created new Telegram bot.
  2. Created new Chat, invited myself and bot in it.
  3. Started ./prometheus_bot -c config.yml
  4. Run make test without specification of TELEGRAM_CHATID:
$ make test
bash t/curl.t
1..2
not ok 1 - simpe.json
# 404
not ok 2 - noGenURL.json
# 404

This lead to 404 responses from prometheus_bot.

  1. Found out Chat Id and run tests with TELEGRAM_CHATID:
$ make test TELEGRAM_CHATID=-...
bash t/curl.t
1..2
not ok 1 - simpe.json
not ok 2 - noGenURL.json

This lead to panic. Here is prometheus_bot log for the whole session:

$ ./prometheus_bot -c config.yml
Authorized on account SomeBot
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /ping/:chatid             --> main.GET_Handling (3 handlers)
[GIN-debug] POST   /alert/:chatid            --> main.POST_Handling (3 handlers)
[GIN-debug] Listening and serving HTTP on :9087
[GIN] 2017/03/06 - 22:17:30 | 404 |         645ns | 127.0.0.1 |   POST    /alert/
[GIN] 2017/03/06 - 22:17:30 | 404 |         628ns | 127.0.0.1 |   POST    /alert/
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0xc8 pc=0x4012aa]

goroutine 50 [running]:
panic(0x8f5180, 0xc820010170)
        /usr/lib/go-1.6/src/runtime/panic.go:481 +0x3e6
main.telegramBot(0xc8200771a0)
        /home/bob/stuff/kubernetes/prometheus_bot/main.go:88 +0x2aa
created by main.main
        /home/bob/stuff/kubernetes/prometheus_bot/main.go:138 +0x8f7
@powerman
Copy link
Contributor

powerman commented Mar 7, 2017

@hryamzik: looks like update.Message should be checked for nil at main.go:88.

@hryamzik
Copy link
Collaborator

hryamzik commented Mar 7, 2017

We can check it for nil but what should we do? If token is invalid there's no reason to run.

@powerman
Copy link
Contributor

powerman commented Mar 7, 2017

what should we do?

Do. Not. Crash. :)

@rutsky
Copy link
Contributor Author

rutsky commented Mar 7, 2017

If token is invalid there's no reason to run.

Well, if configuration is incorrect it should be handled and reported (probably with message and service exit with non-zero code).

BTW, bot token hasn't changed between described here failure and successful usage in the following runs, so I don't think this error is caused by incorrect bot access token.

@hryamzik
Copy link
Collaborator

hryamzik commented Apr 9, 2017

@leominov because you can ask bot for chat ID.

@rutsky I believe crash results in non-zero exit code. PRs are welcomed. ;-)

aminvakil added a commit that referenced this issue Dec 19, 2024
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

No branches or pull requests

4 participants
@rutsky @powerman @hryamzik and others