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

Crash when receiving webhook via MS Teams channel #1141

Closed
bionemesis opened this issue May 20, 2020 · 2 comments
Closed

Crash when receiving webhook via MS Teams channel #1141

bionemesis opened this issue May 20, 2020 · 2 comments
Labels

Comments

@bionemesis
Copy link

bionemesis commented May 20, 2020

Describe the bug
We have our PSA (Syncro https://syncromsp.com/) send notifications to MS Teams via webhook. When these notifications are received, matterbridge crashes. We have not tried other webhooks, but regular messages seem to work fine.

To Reproduce
Obviously not something everyone can do as the webhook post is coming from a paid service

Expected behavior
We are expecting the notification to be synchronized to Mattermost

Screenshots/debug logs

Debug logs
sudo /opt/matterbridge/matterbridge -conf /etc/matterbridge/bridge.toml -debug
[0000]  INFO main:         Enabling debug logging.
[0000]  INFO main:         Running version 1.17.4 6c442e23
[0000]  INFO router:       Parsing gateway gw
[0000]  INFO router:       Starting bridge: mattermost.mymattermost 
[0000]  INFO mattermost:   Connecting using login/password (sending and receiving)
[0000]  INFO mattermost:   Connecting bridge (team: our-team) on mm.domain.tld:443
[0000]  INFO matterclient: Found version 5.21.0.5.21.0.7257b40f883e103cbd9d764a3d679c4e.false
[0000]  INFO matterclient: found 5 users in team our-team
[0000]  INFO mattermost:   Connection succeeded
[0000]  INFO mattermost:   mattermost.mymattermost: joining tickets (ID: ticketsmattermost.mymattermost)
[0000]  INFO router:       Starting bridge: msteams.teams 
[0000] DEBUG mattermost:   Choosing login/password based receiving
[0001]  INFO msteams:      Connection succeeded
[0001]  INFO msteams:      msteams.teams: joining 19:XXXXXX@thread.tacv2 (ID: 19:XXXXXX@thread.tacv2msteams.teams)
[0001]  INFO main:         Gateway(s) started succesfully. Now relaying messages
[0001] DEBUG msteams:      getting initial messages
[0001] DEBUG msteams:      got 3 messages
[0006] DEBUG msteams:      polling for messages
[0006] DEBUG msteams:      got 3 messages
[0011] DEBUG msteams:      got 3 messages
[0017] DEBUG msteams:      got 3 messages
[0022] DEBUG msteams:      got 3 messages
[0028] DEBUG msteams:      got 3 messages
[0033] DEBUG msteams:      got 4 messages
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x12c2117]

goroutine 45 [running]:
github.com/42wim/matterbridge/bridge/msteams.(*Bmsteams).poll(0xc00036d260, 0xc0001130b0, 0x30, 0x0, 0x0)
        /go/src/github.com/42wim/matterbridge/bridge/msteams/msteams.go:161 +0x417
github.com/42wim/matterbridge/bridge/msteams.(*Bmsteams).JoinChannel.func1(0xc00036d260, 0xc0001130b0, 0x30)
        /go/src/github.com/42wim/matterbridge/bridge/msteams/msteams.go:76 +0x61
created by github.com/42wim/matterbridge/bridge/msteams.(*Bmsteams).JoinChannel
        /go/src/github.com/42wim/matterbridge/bridge/msteams/msteams.go:74 +0x53

Environment (please complete the following information):

  • OS: Ubuntu 18.04
  • Matterbridge version: /opt/matterbridge/matterbridge -version
    version: 1.17.4 6c442e2

Additional context
bridge.toml:

[msteams.teams]
TenantID="xxx"
ClientID="xxx"
TeamID="xxx"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

[mattermost.mymattermost]
#The mattermost hostname. (do not prefix it with http or https)
Server="mm.domain.tld:443"

#the team name as can be seen in the mattermost webinterface URL
#in lowercase, without spaces
Team="our-team"

#login/pass of your bot.
#Use a dedicated user for this and not your own!
Login="bridge"
Password="xxx"

RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
PrefixMessagesWithNick=true

[[gateway]]
name="gw"
enable=true

[[gateway.inout]]
account = "mattermost.mymattermost"
channel = "tickets"

[[gateway.inout]]
account="msteams.teams"
channel="xxxxxxxx@thread.tacv2"
@bionemesis bionemesis added the bug label May 20, 2020
@bionemesis
Copy link
Author

bionemesis commented May 20, 2020

Thought it might be helpful to see the JSON that Syncro is sending:

{
  "@type": "MessageCard",
  "@context": "https://schema.org/extensions",
  "summary": "A Ticket was created \n\n Customer: Customer,\nNumber: 6618,\nSubject: Test, \nType: Software, \nInitial Issue: Test",
  "themeColor": "0078D7",
  "title": "Ticket",
  "sections": [
    {
      "text": "A Ticket was created \n\n Customer: Customer,\nNumber: 6618,\nSubject: Test, \nType: Software, \nInitial Issue: Test"
    }
  ],
  "potentialAction": [
    {
      "@type": "OpenUri",
      "name": "View",
      "targets": [
        {
          "os": "default",
          "uri": "https://xxxx.syncromsp.com/tickets/xxxx"
        }
      ]
    }
  ]
}

42wim added a commit that referenced this issue May 24, 2020
Ignore these messages for now, also add a extra
debug option for msteams so we can dump the whole
message.
@42wim 42wim closed this as completed in 7f7ca69 May 24, 2020
@42wim
Copy link
Owner

42wim commented May 24, 2020

Thanks for the clear report, I fixed the crash in master for now by ignoring messages that are not from users.

I've also added a extra debug option for msteams, you can enable it by debug=true in your [msteams.teams] section.

This will dump the complete message and give more information. Could you please open a new issue requesting notification sync for msteams and paste the debug messages you got from the new debug option.

You can find a test binary here: https://bintray.com/beta/#/42wim/nightly/Matterbridge/v1.17.4-14-g1630b4c?tab=files or just build from master.

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

No branches or pull requests

2 participants