Matttermost, Inc.

Mattermost CLI crash with - invalid memory address or nil pointer dereference

Summary

we use the gitlab omnibus package and want to use mattermost. We set up mattermost and gitlab on same host with two different DNS-Names. Both running on HTTPS.

After a short test with some developers we try to clean up and delete some empty teams called “test” or “Admin”.
If I try to delete the teams with

 sudo -u mattermost ./mattermost -config=/var/opt/gitlab/mattermost/config.json team delete Admin

here you see command and Error out put

sudo -u mattermost ./mattermost -config=/var/opt/gitlab/mattermost/config.json team delete Admin
Have you performed a database backup? (YES/NO):
YES
Are you sure you want to delete the teams specified?  All data will be permanently deleted? (YES/NO):
YES
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x416488]

goroutine 1 [running]:
panic(0xbde860, 0xc4200100c0)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
main.getTeamFromTeamArg(0x7ffc3f3918e4, 0x5, 0x1)
        /var/lib/jenkins/jobs/msr/jobs/platform-release/workspace/src/github.com/mattermost/platform/cmd/platform/teamargs.go:21 +0x28
main.getTeamsFromTeamArgs(0xc4200cd3c0, 0x1, 0x2, 0x3, 0x1, 0x0)
        /var/lib/jenkins/jobs/msr/jobs/platform-release/workspace/src/github.com/mattermost/platform/cmd/platform/teamargs.go:13 +0xa2
main.deleteTeamsCmdF(0x106b700, 0xc4200cd3c0, 0x1, 0x2, 0x0, 0x0)
        /var/lib/jenkins/jobs/msr/jobs/platform-release/workspace/src/github.com/mattermost/platform/cmd/platform/team.go:187 +0xdf
github.com/mattermost/platform/vendor/github.com/spf13/cobra.(*Command).execute(0x106b700, 0xc4200cd1a0, 0x2, 0x2, 0x106b700, 0xc4200cd1a0)
        /var/lib/jenkins/jobs/msr/jobs/platform-release/workspace/src/github.com/mattermost/platform/vendor/github.com/spf13/cobra/command.go:632 +0x23e
github.com/mattermost/platform/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc4200986c0, 0x0, 0x0, 0x0)
        /var/lib/jenkins/jobs/msr/jobs/platform-release/workspace/src/github.com/mattermost/platform/vendor/github.com/spf13/cobra/command.go:722 +0x367
github.com/mattermost/platform/vendor/github.com/spf13/cobra.(*Command).Execute(0xc4200986c0, 0xc42010ea40, 0xb)
        /var/lib/jenkins/jobs/msr/jobs/platform-release/workspace/src/github.com/mattermost/platform/vendor/github.com/spf13/cobra/command.go:681 +0x2b
main.main()
        /var/lib/jenkins/jobs/msr/jobs/platform-release/workspace/src/github.com/mattermost/platform/cmd/platform/mattermost.go:50 +0x49f

I got the same error when calling other command like team add Admin username

Thanks @lvornholt for the report! We’ve created a bug report here to investigate https://mattermost.atlassian.net/browse/PLT-5682

My organization is running GitLab Community 9.0 using the integrated Mattermost and have the same problem (not being able to delete teams using the cli).

I was creating nested groups in GL 9.0 and there is a checkbox to automatically create an associated Mattermost team. I’d like to delete these teams.

Any response on this issue from @jasonblais?

@sawdustgang hi, could you try running the command from inside the folder /var/opt/gitlab/mattermost/bin, if you haven’t yet?

cd /var/opt/gitlab/mattermost/bin
sudo su mattermost ./mattermost team delete Admin -c /var/opt/gitlab/mattermost/config.json 

Thank you for the response!

The mattermost cli that comes bundled with GitLab Community Edition is in the following directory, not in the /var/opt/gitlab/mattermost/bin directory:

/opt/gitlab/embedded/bin

So, I cd to the /opt/gitlab/embedded/bin directory.

I don’t think I have an Admin team so I’ll use the team wtas which is one of the ones I need to delete.

sudo su mattermost ./mattermost team delete wtas -c /var/opt/gitlab/mattermost/config.json

gives me

./mattermost: /var/opt/gitlab/mattermost/config.json: Permission denied

even though config.json is owned by mattermost

The command

sudo -u mattermost ./mattermost team delete wtas -c /var/opt/gitlab/mattermost/config.json

give me

Have you performed a database backup? (YES/NO): YES
Are you sure you want to delete the teams specified? All data will be permanently deleted? (YES/NO): YES
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x414f58]
goroutine 1 [running]:
panic(0xc72560, 0xc4200100c0)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
main.getTeamFromTeamArg(0x7ffe02d8b8ac, 0x4, 0x1)
/home/ubuntu/workspace/msr/platform-release/src/github.com/mattermost/platform/cmd/platform/teamargs.go:21 +0x28
main.getTeamsFromTeamArgs(0xc42069e480, 0x1, 0x3, 0x3, 0x1, 0x0)
/home/ubuntu/workspace/msr/platform-release/src/github.com/mattermost/platform/cmd/platform/teamargs.go:13 +0xa2
main.deleteTeamsCmdF(0x11475a0, 0xc42069e480, 0x1, 0x3, 0x0, 0x0)
/home/ubuntu/workspace/msr/platform-release/src/github.com/mattermost/platform/cmd/platform/team.go:186 +0xdf
github.com/mattermost/platform/vendor/github.com/spf13/cobra.(*Command).execute(0x11475a0, 0xc42069e3f0, 0x3, 0x3, 0x11475a0, 0xc42069e3f0)
/home/ubuntu/workspace/msr/platform-release/src/github.com/mattermost/platform/vendor/github.com/spf13/cobra/command.go:643 +0x23e
github.com/mattermost/platform/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc421152240, 0x0, 0x0, 0x0)
/home/ubuntu/workspace/msr/platform-release/src/github.com/mattermost/platform/vendor/github.com/spf13/cobra/command.go:734 +0x367
github.com/mattermost/platform/vendor/github.com/spf13/cobra.(*Command).Execute(0xc421152240, 0xc420010770, 0xb)
/home/ubuntu/workspace/msr/platform-release/src/github.com/mattermost/platform/vendor/github.com/spf13/cobra/command.go:692 +0x2b
main.main()
/home/ubuntu/workspace/msr/platform-release/src/github.com/mattermost/platform/cmd/platform/mattermost.go:50 +0x49f

Yes, that was merely a sample command based on what was early written, glad you adjusted to your needs.

And does it get deleted afterward despite the errors?

also if you could confirm the permissions at /var/opt/gitlab/mattermost/config.json with ls -la /var/opt/gitlab/mattermost/config.json that would be helpful.

The group (wtas in my case) does not get deleted.

Permissions are:

what version of mattermost is GL9 installing for you? guess I ran out of ideas, the permissions look OK, the config.json~ was probably a left over copy from some command

perhaps you might want to try re-installing the latest binary version instead… I know you’re using GL for the simplicity but its an option.

Version: 3.7.0
Build Number: 3.7.2
Build Date: Fri Mar 17 19:07:10 UTC 2017
Build Hash: f4473cf312d09a53a57312745963aee334e251cb
Build Enterprise Ready: false
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x419478]

Hi there,

I just want to mention that we have the same issues here. We are also running the same mattermost version on a gitlab installation and would like to use the CLI.

I’ll be happy to answer questions.

Please update when a solution arises.

Thanks

same problem here

platform user deactivate user_name

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xbfbf48]

goroutine 1 [running]:
main.getUserFromUserArg(0x7ffcea877781, 0x9, 0x1)
/var/lib/jenkins/jobs/msr/jobs/d/jobs/platform-release/workspace/src/github.com/mattermost/platform/cmd/platform/userargs.go:21 +0x28
main.getUsersFromUserArgs(0xc4200c5760, 0x1, 0x2, 0x26, 0x6, 0x7ffcea87774a)
/var/lib/jenkins/jobs/msr/jobs/d/jobs/platform-release/workspace/src/github.com/mattermost/platform/cmd/platform/userargs.go:13 +0xa2
main.changeUsersActiveStatus(0xc4200c5760, 0x1, 0x2, 0x0)
/var/lib/jenkins/jobs/msr/jobs/d/jobs/platform-release/workspace/src/github.com/mattermost/platform/cmd/platform/user.go:162 +0x43
main.userDeactivateCmdF(0x11a6480, 0xc4200c5760, 0x1, 0x2, 0x0, 0x0)
/var/lib/jenkins/jobs/msr/jobs/d/jobs/platform-release/workspace/src/github.com/mattermost/platform/cmd/platform/user.go:189 +0xc9
github.com/mattermost/platform/vendor/github.com/spf13/cobra.(*Command).execute(0x11a6480, 0xc4200c55a0, 0x2, 0x2, 0x11a6480, 0xc4200c55a0)
/var/lib/jenkins/jobs/msr/jobs/d/jobs/platform-release/workspace/src/github.com/mattermost/platform/vendor/github.com/spf13/cobra/command.go:643 +0x3ef
github.com/mattermost/platform/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42008c6c0, 0x0, 0x0, 0x0)
/var/lib/jenkins/jobs/msr/jobs/d/jobs/platform-release/workspace/src/github.com/mattermost/platform/vendor/github.com/spf13/cobra/command.go:734 +0x339
github.com/mattermost/platform/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42008c6c0, 0xc42011a930, 0xb)
/var/lib/jenkins/jobs/msr/jobs/d/jobs/platform-release/workspace/src/github.com/mattermost/platform/vendor/github.com/spf13/cobra/command.go:692 +0x2b
main.main()
/var/lib/jenkins/jobs/msr/jobs/d/jobs/platform-release/workspace/src/github.com/mattermost/platform/cmd/platform/mattermost.go:50 +0x4b2

Hi @sawdustgang, @lucasnap and @gitthismoney,

Thanks for your feedback,

Since your posts were made, GitLab has released v9.2 and the latest version of Mattermost (v3.9) shipped on May 16th.

Could we have your help upgrading to the latest versions and letting us know whether your issue still persists?

Thanks!

problem still exists for me, was on 3.7 and just upgraded to 3.9.

Some commands still seem to work, but all of them i’ve tried except the help command give the
panic: runtime error: invalide memory address or nil pointer dereference message and a stacktrace

Update, to run these commands with the gitlab installation you have to cd into this directory and run them

/opt/gitlab/embedded/service/mattermost

I think someone should document that somewhere, as it’s immediately obvious to no one.

Thanks @KyleGobel!

I created a GitHub PR: Added instructions for using CLI on GitLab Omnibus #1248

Take a look and let me know if it works for you. If you have a GitHub account, you can leave a comment on the PR itself.