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

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.