p.API.KVSet causing RPC error?

I’m attempting to update the archived GitHub - mattermost/mattermost-plugin-google-calendar: Mattermost Google Calendar Plugin plugin as a stopgap until the new gcal plugin is ready. The plugin mostly seems to work, but notifications are not working. I’ve tried implementing the suggestion at Notifications are broken · Issue #12 · mattermost/mattermost-plugin-google-calendar · GitHub , and while it compiles, I’m running into other issues before it even gets there.

My forked repo is at GitHub - FFdhorkin/mattermost-plugin-google-calendar at update

The connect window shows a 500 error once I approve the integration.

In Mattermost logs, I see this:

{“timestamp”:“2023-03-31 19:07:41.532 Z”,“level”:“error”,“msg”:“Plugin failed to ServeHTTP, RPC call failed”,“caller”:“plugin/client_rpc.go:423”,“plugin_id”:“com.mattermost.google-calendar”,“error”:“unexpected EOF”}
{“timestamp”:“2023-03-31 19:07:41.532 Z”,“level”:“error”,“msg”:“plugin process exited”,“caller”:“plugin/hclog_adapter.go:79”,“plugin_id”:“com.mattermost.google-calendar”,“wrapped_extras”:“pathplugins/com.mattermost.google-calendar/server/dist/plugin-linux-amd64pid72495errorexit status 2”}
{“timestamp”:“2023-03-31 19:07:41.962 Z”,“level”:“error”,“msg”:“Plugin failed to ServeHTTP, RPC call failed”,“caller”:“plugin/client_rpc.go:423”,“plugin_id”:“com.mattermost.google-calendar”,“error”:“connection is shut down”}
{“timestamp”:“2023-03-31 19:07:46.963 Z”,“level”:“error”,“msg”:“Plugin failed to ServeHTTP, muxBroker couldn’t accept connection”,“caller”:“plugin/client_rpc.go:378”,“plugin_id”:“com.mattermost.google-calendar”,“serve_http_stream_id”:7,“error”:“timeout waiting for accept”}
{“timestamp”:“2023-03-31 19:07:46.963 Z”,“level”:“error”,“msg”:“Plugin failed to ServeHTTP, muxBroker couldn’t Accept request body connection”,“caller”:“plugin/client_rpc.go:397”,“plugin_id”:“com.mattermost.google-calendar”,“error”:“timeout waiting for accept”}

This seems to be happening in two places, but I can’t figure out the cause for the life of me.

In server/utils.go method setupCalendarWatch, it fails on this line: p.API.KVSet(userID+"watchChannel", watchChannelJSON)

I was wondering if watchChannelJson was corrupted somehow… but I printed it and it looks fine as far as I can tell.

Sometimes it manages to get past that, in which case it fails in server/api.go method CreateBotDMPost on the first line: channel, err := p.API.GetDirectChannel(userID, p.botID)

I’ve tried using p.client.KV.Set(userID+"watchChannel", watchChannelJSON) and p.client.Channel.GetDirect, but this didn’t seem to make a difference.

I’ve tried searching for the errors, as well as the names of this message… and haven’t been able to find anything useful (there were some similar errors with different causes). I also tried looking at the new/unfinished gcal plugin to see if maybe I could backport some of it, but that doesn’t seem particularly feasible.