mattermost/server/cmd/mmctl
Ben Schumacher 93ab9a4ccc
[MM-68351] Fix nil pointer panic in mmctl websocket command on connection failure (#36138)
* fix(mmctl): prevent nil pointer panic in websocket command on connection failure

When the WebSocket connection fails immediately, Listen() closes EventChannel
via defer. Reading from a closed channel with a plain receive returns nil,
causing a panic in ToJSON(). Switch to range so the loop exits cleanly,
add a nil guard, and surface ListenError to the caller.

Fixes MM-68351

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(mmctl): add unit tests for websocket nil event and ListenError handling

Extracts the event-processing loop into processWebSocketEvents to enable
unit testing, and adds tests covering the nil-event skip and error surfacing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(mmctl): add happy-path subtest for processWebSocketEvents

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 15:32:34 +02:00
..
client mmctl: Add support for listing user roles through mmctl (#34064) 2026-03-18 11:43:13 +00:00
commands [MM-68351] Fix nil pointer panic in mmctl websocket command on connection failure (#36138) 2026-04-23 15:32:34 +02:00
docs Remove vestigial MySQL support (#34865) 2026-01-20 21:01:59 +00:00
mocks [MM-67859] Update license renewal and expiry email branding (#35701) 2026-04-04 20:30:36 -03:00
printer Improve mmctl output by filtering escape sequences (#35191) 2026-02-05 15:32:35 +01:00
mmctl.go MM-53032: Fix module path after repo rename (#23689) 2023-06-11 10:54:35 +05:30
README.md Add a simple mmctl README file (#23638) 2023-10-10 10:34:08 +02:00

mmctl

mmctl is a remote CLI tool that lets you manage your Mattermost instance from the terminal.

The project's documentation can be accessed within the the Mattermost documentation.