Skip to content

Uncaught error in getUserFromMention #4460

@gnprice

Description

@gnprice

One of our more widespread issues reported by Sentry is this one:

undefined is not an object (evaluating 'o.split')

with stack

    const [userFullName, userIdRaw] = unformattedMessage.split('|');

in getUserFromMention < MentionWarnings.

So it seems that unformattedMessage here is undefined. The fuller source listng is

  getUserFromMention = (completion: string): UserOrBot | void => {
    const { usersById } = this.props;

    const unformattedMessage = completion.split('**')[1];
    const [userFullName, userIdRaw] = unformattedMessage.split('|');

so it looks like this would happen if completion.split('**') returns an array of less than two elements. In particular this would happen if completion doesn't contain '**'.

Because this is regularly affecting users, and I believe it's causing a crash for them, it would be good to fix.

I think this is ripe for some debugging.

  • The first goal would be to try to reproduce it -- go to the compose box and try to enter some text that triggers this bug.
  • A useful step for trying to do that would be to read a bit more of the code that leads to here, and try to see when getUserFromMention is called. It seems like that function is assuming that its argument string will contain ** whenever it gets called, but that that isn't always true.
  • Once we have a clear reproduction, I suspect the fix may be relatively easy -- the debugging may be the main part of the work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions