Skip to content

Slack adapter mention regex mangles email addresses #392

@thomasmol

Description

@thomasmol

Bug Description

The regex /(?<!<)@(\w+)/g in packages/adapter-slack/src/markdown.ts converts @word to <@word> for Slack mentions. The lookbehind only excludes < before @, so email addresses like user@example.com get rewritten to user<@example>.com. This also breaks <mailto:user@example.com> links.

private convertMentionsToSlack(text: string): string {
return text.replace(/(?<!<)@(\w+)/g, "<@$1>");
}

Steps to Reproduce

Post a message containing an email address through the Slack adapter:
await adapter.postChannelMessage('slack:C1234', 'Contact user@example.com for help');

Expected Behavior

Slack displays: Contact user@example.com for help with the email auto-linked.

Actual Behavior

Slack displays: Contact user@example.com for help with @example rendered as a broken user mention, because the text sent to Slack is Contact user<@example>.com for help.

This also affects mailto: links — mailto:user@example.com becomes <mailto:user<@example>.com>.

Code Sample

Chat SDK Version

4.26

Node.js Version

24

Platform Adapter

Slack

Operating System

macOS

Additional Context

Potential fix is to add \w to the lookbehind:
/(?<![<\w])@(\w+)/g

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions