Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is ChatPostMessageRequest.linkNames serialized? #1442

Open
Spencer857 opened this issue Feb 20, 2025 · 3 comments
Open

How is ChatPostMessageRequest.linkNames serialized? #1442

Spencer857 opened this issue Feb 20, 2025 · 3 comments
Labels
question M-T: User needs support to use the project

Comments

@Spencer857
Copy link

I want to send a formatted message via chat.postMessage endpoint. My text is properly escaped and I don't want Slack to guess any escaping. Slack formatting guide (https://api.slack.com/reference/surfaces/formatting#automatic-parsing__disabling-automatic-parsing) says:

If you want to disable automatic parsing, you have a couple of options depending on the type of text:
...

  • For the top-level text field, or text in secondary message attachments, as long as you exclude the link_names argument when publishing, this will be disabled by default.

...

So I'm looking for an option to exclude the link_names argument. I see that there's ChatPostMessageRequest.linkNames field of type boolean. Will setting it to false exclude the link_names argument? It's a bit confusing because I would rather expect some Boolean or Integer field where I had to assing it to null.

@Spencer857
Copy link
Author

I've found relevant code fragment here https://github.com/slackapi/java-slack-sdk/blob/main/slack-api-client/src/main/java/com/slack/api/methods/RequestFormBuilder.java#L1516

// ...
setIfNotNull("link_names", req.isLinkNames(), form);
// ...

and it's lacking this important functionality. It serializes true to 1 and false to 0. But there's no possibility of specifying no value because type is boolean but should be Boolean.

@WilliamBergamin
Copy link
Contributor

Hi @Spencer857 thanks for writing in 💯

Setting link_names to false should prevent slack from pattern matching link names in your message, are you experiencing a different behavior?

Also from this doc it seems like link_names no longer supports linking individual users

Find and link user groups. No longer supports linking individual users; use syntax shown in Mentioning Users instead.

Alternatively you could try to post your message as a rich_text_preformatted block element, this should prevent slack from guessing any escaping 🤔

@WilliamBergamin WilliamBergamin added question M-T: User needs support to use the project and removed untriaged labels Feb 21, 2025
@Spencer857
Copy link
Author

Am I right that link_names is false by default in Bolt for Java?

Alternatively you could try to post your message as a rich_text_preformatted block element

I cannot use blocks. It needs to be text because our bot is sending messages on a user's behalf, and this message must be editable by them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

2 participants