42wim/matterircd

Panic on testing newly implemented prefixContext

Closed this issue · 5 comments

Hi,

Replying to an old thread in a test channel causes matterircd to crash:

time="2020-08-30T12:01:40Z" level=debug msg="handleWsActionPost() user hloeung sent Testing"
time="2020-08-30T12:01:40Z" level=debug msg="&model.Post{Id:\"x4sbaop1w3gzmrc7q86d5s7m7c\", CreateAt:1598788874816, UpdateAt:1598788874816, EditAt:0, DeleteAt:0, IsPinned:false, UserId:\"m45ssk4t4bfwufbghxnmj89d4a\", ChannelId:\"pkn6xmxn37rix85w4uurjpkoqo\", RootId:\"i7k3bp6pcigaj8gabad3iy9iur\", ParentId:\"i7k3bp6pcigaj8gabad3iy9iur\", OriginalId:\"\", Message:\"Testing\", MessageSource:\"\", Type:\"\", propsMu:sync.RWMutex{w:sync.Mutex{state:0, sema:0x0}, writerSem:0x0, readerSem:0x0, readerCount:0, readerWait:0}, Props:model.StringInterface{}, Hashtags:\"\", Filenames:model.StringArray(nil), FileIds:model.StringArray(nil), PendingPostId:\"m45ssk4t4bfwufbghxnmj89d4a:1598788874605\", HasReactions:false, ReplyCount:0, Metadata:(*model.PostMetadata)(0xc0003de3f0)}"
time="2020-08-30T12:01:40Z" level=debug msg="in handleWsMessage8"
time="2020-08-30T12:01:40Z" level=debug msg="in handleChannelMessageEvent" module=matterircd
time="2020-08-30T12:01:40Z" level=debug msg="MMUser WsReceiver: &model.WebSocketEvent{Event:\"channel_viewed\", Data:map[string]interface {}{\"channel_id\":\"pkn6xmxn37rix85w4uurjpkoqo\"}, Broadcast:(*model.WebsocketBroadcast)(0xc0006002c0), Sequence:33, precomputedJSON:(*model.precomputedWebSocketEventJSON)(nil)}"
panic: assignment to entry in nil map

goroutine 73 [running]:
github.com/42wim/matterircd/mm-go-irckit.(*User).prefixContext(0xc00026a000, 0xc0008741e0, 0x1a, 0xc000874160, 0x1a, 0xc0008742a0, 0x1a, 0xc0009d4790, 0x6, 0x0, ...)
        /home/hloeung/development/matterircd/mm-go-irckit/userbridge.go:737 +0x89b
github.com/42wim/matterircd/mm-go-irckit.(*User).handleChannelMessageEvent(0xc00026a000, 0xc0009c8f30)
        /home/hloeung/development/matterircd/mm-go-irckit/userbridge.go:216 +0x3f7
github.com/42wim/matterircd/mm-go-irckit.(*User).handleEventChan(0xc00026a000, 0xc0000c0480)
        /home/hloeung/development/matterircd/mm-go-irckit/userbridge.go:54 +0x414
created by github.com/42wim/matterircd/mm-go-irckit.(*User).loginTo
        /home/hloeung/development/matterircd/mm-go-irckit/userbridge.go:678 +0x1a1

Rather than use 000 to fff, can we just use the first few characters of the parent postID? Kind of like git short commit IDs (e.g. bc878e5 and 33aaad4).

Also, preferably at the end / suffix of the message rather than prefix?

42wim commented

Can you tell me what exactly you did for this panic? how did you reply on an old thread? As it doesn't has a number to reply to?

42wim commented

Rather than use 000 to fff, can we just use the first few characters of the parent postID? Kind of like git short commit IDs (e.g. bc878e5 and 33aaad4).

No, we need consistent numbering for this, especially needed for a5e402e
(also because we need a circular buffer)

Also, preferably at the end / suffix of the message rather than prefix?

No sorry, I'm keeping it at the front for now, makes more sense

Can you tell me what exactly you did for this panic? how did you reply on an old thread? As it doesn't has a number to reply to?

Via the Mattermost UI. Replied there to see what it would look like via IRC client.

42wim commented

Ok, thanks for reporting! fixed now.

Wrt the placement of the numbers, I'm not against a PR that makes an option of this.