42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.66k stars 618 forks source link

Mattermost-IRC bridge crashes when receiving mattermost message #186

Closed bagage closed 7 years ago

bagage commented 7 years ago

Please answer the following questions.

Which version of matterbridge are you using?

0.13.1-dev

If you're having problems with mattermost please specify mattermost version.

3.9.0 (framateam)

Please describe the expected behavior.

I have a Mattermost-IRC bridge that worked great. I tweaked a bit the config and it started crashing. I restored to the initial version but now it keeps crashing.

  1. Wait for the bridge to establish connection
  2. Send a message on mattermost channel expected The message appears in the IRC channel

Please describe the actual behavior.

Instead mattermostbridge crashes:

DEBU[2017-06-04T18:25:27+02:00] WsReceiver: model.WebSocketEvent{Event:"posted", Data:map[string]interface {}{"channel_type":"O", "post":"{\"id\":\"ID\",\"create_at\":1496593593558,\"update_at\":1496593593558,\"edit_at\":0,\"delete_at\":0,\"is_pinned\":false,\"user_id\":\"ID\",\"channel_id\":\"ID\",\"root_id\":\"\",\"parent_id\":\"\",\"original_id\":\"\",\"message\":\"[irc] \\u003cbagage2\\u003e : ok\",\"type\":\"\",\"props\":{},\"hashtags\":\"\",\"pending_post_id\":\"\"}", "sender_name":"USER", "team_id":"ID", "channel_display_name":"NAME", "channel_name":"NAME"}, Broadcast:(*model.WebsocketBroadcast)(0xc420404c00), PreComputeJson:[]uint8(nil)}  module=matterclient
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x6a3053]

goroutine 77 [running]:
panic(0x9c66a0, 0xc420012120)
    /usr/lib/go-1.7/src/runtime/panic.go:500 +0x1a1
github.com/42wim/matterbridge/matterclient.(*MMClient).parseActionPost(0xc42019eb40, 0xc4201d34a0)
    /tmp/src/github.com/42wim/matterbridge/matterclient/matterclient.go:291 +0x193
github.com/42wim/matterbridge/matterclient.(*MMClient).parseMessage(0xc42019eb40, 0xc4201d34a0)
    /tmp/src/github.com/42wim/matterbridge/matterclient/matterclient.go:266 +0x94
github.com/42wim/matterbridge/matterclient.(*MMClient).WsReceiver(0xc42019eb40)
    /tmp/src/github.com/42wim/matterbridge/matterclient/matterclient.go:249 +0x639
created by github.com/42wim/matterbridge/bridge/mattermost.(*Bmattermost).Connect
    /tmp/src/github.com/42wim/matterbridge/bridge/mattermost/mattermost.go:74 +0x372

Any steps to reproduce the behavior?

Please add your configuration file

[irc]
    [irc.oftc]
    Server="irc.oftc.net:6667"
    Nick="nick"

[mattermost]
    [mattermost.team]
    useAPI=true
    Server="server"
    Team="team"
    Login="login"
    Password="pass"
    PrefixMessagesWithNick=true
    RemoteNickFormat="[{PROTOCOL}] <{NICK}> : "
[[gateway]]
name="mygateway"
enable=true
    [[gateway.inout]]
    account="irc.oftc"
    channel="#testchannel"

    [[gateway.inout]]
    account="mattermost.team"
    channel="channel"

Even when changing irc server/name/channel and mattermost user/channel, the issue persists.

42wim commented 7 years ago

This happens immediately or after a while?

42wim commented 7 years ago

Are you sure about mattermost 3.5.0 ? the is_pinned in your debug log only exists since 3.8.0

bagage commented 7 years ago

Sorry about server version - I was mislead by desktop application. This is a 3.9.0 server (framateam.org).

The crash happens 10 sec after the "posted" event, reliably.

bagage commented 7 years ago

Update: if I install matterbridge in another folder (by changing GOPATH) it works again -- and now I cannot replicate the problem in the initial folder too! Is there any cache file that could explain the issue? (for info initially GOPATH=/tmp/, I changed it to GOPATH=$HOME/tmp).

42wim commented 7 years ago

No, matterbridge has no state. But framateam has lots of users, it could be related to that. I had to make fixes for framateam in the past.

I have an account there too, I'll see if I can reproduce it.

bagage commented 7 years ago

OK, might be indeed related to server loads on framasoft side. For now I cannot reproduce it either - should I bump this once I reproduce it again?

42wim commented 7 years ago

Reopen if it happens again, panic should be fixed now though in master