Message Barker

Message Barker

10.4k Downloads

LUA Error - Conflict with Identity-2

bolerro opened this issue ยท 2 comments

commented

Message: Interface\AddOns\Identity-2\Identity-2.lua:756: bad argument #1 to 'find' (string expected, got nil)
Time: Sun Mar 7 23:27:29 2021
Count: 3
Stack: Interface\AddOns\Identity-2\Identity-2.lua:756: bad argument #1 to 'find' (string expected, got nil)
[C]: ?
[C]: in function find' Interface\AddOns\Identity-2\Identity-2.lua:756: in function <Interface\AddOns\Identity-2\Identity-2.lua:751> (tail call): ? Interface\AddOns\MessageBarker\MessageBarker.lua:38: in function BarkMessage'
Interface\AddOns\MessageBarker\MessageRow.lua:62: in function `RunClicked'
[string ":OnClick"]:1: in function <[string ":OnClick"]:1>

Locals:

commented

Identity-2 works fine without this addon installed. Added Barker and now I get this error only when trying to use Send in the Barker window.

commented

There are two points of failure causing this bug.

The first is in MessageBarker which I can fix by not calling SendChatMessage if the channel ID is 0 (meaning there is no channel found). If there is not a valid channel ID when the message type is "CHANNEL", there is never a need to call SendChatMessage.

SendChatMessage doesn't throw an error when it is called with a channel argument of 0, which is why this was never of any relevance before. MessageBarker shouldn't actually have to check for this scenario because of this. The fault is more on Identity's end where it is calling find with invalid parameters. Since there is no downside for MessageBarker to check this, I will make the change. However, Identity ought to update their code because it is creating a hook which affects every addon that calls this global SendChatMessage function and should be properly coded.

The second point of failure is in Indentity's SendChatMessage hook. Identity needs to also check for channel == 0 and fail gracefully before calling GetChannelName. It also couldn't hurt to check for a nil name before calling find.
https://github.com/Lavindar/identity-2/blob/da1ef3c459bc59e84f13600504f647b848b1d150/Identity-2.lua#L756