Gitlab integration fails with stack trace

Hi,

I just installed gitlab with LDAP (9.5.5-ce, working fine), installed Mattermost (4.2.0, without gitlab first, also fine with nginx ) and now I wanted to connect both. Everything is on Debian Stretch KVM VM.
I added the application manually in gitlab and copied the authentication stuff to mattermost. I got redirected correctly to gitlab and after clicking on the gitlab authorize button, i’ll get redirected back to mattermost and end in an 500. The log states stack trace error. I also reinstalled the mattermost server twice and setup everything again, but still this hard error:

Sep 22 20:59:29 mattermost platform[1289]: [2017/09/22 20:59:29 CEST] [EROR] Please check the ep 22 21:05:54 mattermost platform[1289]: [2017/09/22 21:05:54 CEST] [EROR] Please check the std error output for the stack trace
Sep 22 21:05:54 mattermost platform[1289]: goroutine 2585 [running]:
Sep 22 21:05:54 mattermost platform[1289]: runtime/debug.Stack(0x1af6ec0, 0xc421d96640, 0x13f7d53)
Sep 22 21:05:54 mattermost platform[1289]:         /usr/local/go/src/runtime/debug/stack.go:24 +0x79
Sep 22 21:05:54 mattermost platform[1289]: runtime/debug.PrintStack()
Sep 22 21:05:54 mattermost platform[1289]:         /usr/local/go/src/runtime/debug/stack.go:16 +0x22
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/vendor/github.com/gorilla/handlers.recoveryHandler.log(0x1af6fc0, 0xc421906288, 0x1af7000, 0x1b741e0, 0x1, 0xc421d965e0, 0x1, 0x1)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/vendor/github.com/gorilla/handlers/recovery.go:89 +0x70
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/vendor/github.com/gorilla/handlers.recoveryHandler.ServeHTTP.func1(0x1b01980, 0xc4227ee460, 0x1af6fc0, 0xc421906288, 0x1af7000, 0x1b741e0, 0x1)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/vendor/github.com/gorilla/handlers/recovery.go:74 +0xef
Sep 22 21:05:54 mattermost platform[1289]: panic(0x125c460, 0x1b3c120)
Sep 22 21:05:54 mattermost platform[1289]:         /usr/local/go/src/runtime/panic.go:489 +0x2cf
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/model/gitlab.(*GitLabProvider).GetAuthDataFromJson(0x1b741e0, 0x1af6840, 0xc421d8f8f0, 0x6, 0xc420086628)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/model/gitlab/gitlab.go:109 +0x3e
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/app.LoginByOAuth(0xc4228821ec, 0x6, 0x7fd63049aa88, 0xc421daf360, 0x0, 0x0, 0x0, 0x0)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/app/oauth.go:450 +0x203
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/app.CompleteOAuth(0xc4228821ec, 0x6, 0x1afde40, 0xc421daf360, 0x0, 0x0, 0xc421db87b0, 0x0, 0x0)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/app/oauth.go:430 +0x2d4
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/api4.completeOAuth(0xc4228822d0, 0x1b01980, 0xc4227ee460, 0xc422876400)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/api4/oauth.go:430 +0x50e
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/api4.handler.ServeHTTP(0x1421460, 0xc421000000, 0x1b01980, 0xc4227ee460, 0xc422876400)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/api4/context.go:167 +0x9d0
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/api4.(*handler).ServeHTTP(0xc422821010, 0x1b01980, 0xc4227ee460, 0xc422876400)
Sep 22 21:05:54 mattermost platform[1289]:         <autogenerated>:1 +0x83
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc422271130, 0x1b01980, 0xc4227ee460, 0xc422876400)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/vendor/github.com/gorilla/mux/mux.go:114 +0x10c
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/app.(*CorsWrapper).ServeHTTP(0xc421906288, 0x1b01980, 0xc4227ee460, 0xc422876200)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/app/server.go:78 +0x78
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/vendor/github.com/gorilla/handlers.recoveryHandler.ServeHTTP(0x1af6fc0, 0xc421906288, 0x1af7000, 0x1b741e0, 0x1, 0x1b01980, 0xc4227ee460, 0xc422876200)
Sep 22 21:05:54 mattermost platform[1289]:         /var/lib/jenkins/jobs/msr/jobs/d/jobs/enterprise-release/workspace/src/github.com/mattermost/platform/vendor/github.com/gorilla/handlers/recovery.go:78 +0xb9
Sep 22 21:05:54 mattermost platform[1289]: github.com/mattermost/platform/vendor/github.com/gorilla/handlers.(*recoveryHandler).ServeHTTP(0xc4219680c0, 0x1b01980, 0xc4227ee460, 0xc422876200)
Sep 22 21:05:54 mattermost platform[1289]:         <autogenerated>:59 +0x87
Sep 22 21:05:54 mattermost platform[1289]: net/http.serverHandler.ServeHTTP(0xc421b7e580, 0x1b01980, 0xc4227ee460, 0xc422876200)
Sep 22 21:05:54 mattermost platform[1289]:         /usr/local/go/src/net/http/server.go:2568 +0x92
Sep 22 21:05:54 mattermost platform[1289]: net/http.(*conn).serve(0xc422580f00, 0x1b026c0, 0xc421944940)
Sep 22 21:05:54 mattermost platform[1289]:         /usr/local/go/src/net/http/server.go:1825 +0x612
Sep 22 21:05:54 mattermost platform[1289]: created by net/http.(*Server).Serve
Sep 22 21:05:54 mattermost platform[1289]:         /usr/local/go/src/net/http/server.go:2668 +0x2ce
Sep 22 21:05:54 mattermost platform[1289]: [2017/09/22 21:05:54 CEST] [EROR] [runtime error: invalid memory address or nil pointer dereference]

Any idea how to debug deeper? What can I do?

Accoding to nginx’s access.log, the request also looks fine:

1.2.3.4 - - [22/Sep/2017:21:05:54 +0200] "GET /signup/gitlab/complete?code=12d574629c9fadfd007b65b7b8771234d8fc539447f4ee92ece797f15f424933&state=eyJhY3Rpb24iOiJsb2dpbiIsInRva2VuIjoibzF6bXhjeXQ3MXdw1234OHd0ZXVkNGVrZGl0OXg4cnl1aG1vZ25ta2F1Nnlhb3JqcXdpajdqbjRtaTk0b2txYSJ9 HTTP/2.0" 500 189 "https://gitlab.fqdn.local/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"

Hi @lnxbil,

Did you install Mattermost on its own, or are you using the version with the GitLab Omnibus?

Also, are those logs from GitLab, or from Mattermost itself? Maybe there’s something else of use in Mattermost logs at either /var/log/gitlab/mattermost/mattermost.log or /var/log/gitlab/mattermost/mattermost.logmattermost.log depending on your version of GitLab. I don’t think there should be anything more private than IP addresses in there, but if you’d want to send them along, you can either post them here or sign up to our public https://pre-release.mattermost.com server and send them to me in a private message (my username over there is @harrison).

Hi @hmhealey,

Thank you for your feedback.

This was the standalone version of mattermost. I only tried Gitlab to have LDAP in the CE version. The “real” mattermost logfile did only show the entry to look at the stdout/stderr. The aforementioned logentries was taken from systemd/journalctl.

I just switched to the omnibus version after finding out that gitlab ships with their own mattermost version and the integration worked there without any issues. The version is also quite similar after the upgrade of gitlab last week.

So I think that I’m going to use the omnibus version due to its ‘working condition’. I just wanted to report this strange crash “kind’a upstream”, yet I know myself that debugging something I cannot reproduce is almost impossible.

Glad to hear that fixed it. I think the latest GitLab Omnibus includes Mattermost 4.2, so you’re up to date with our latest release as well. Hopefully it was just something misconfigured between the two then.