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

Microsoft Teams - Invalid Message Formatting #2020

Open
redrathnure opened this issue Jun 22, 2021 · 5 comments
Open

Microsoft Teams - Invalid Message Formatting #2020

redrathnure opened this issue Jun 22, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@redrathnure
Copy link

Describe the bug

Getting incorrect formatted message using MS Teams plugin. Text looks like escaped version with special characters like \n. For example:
screes_actual

To Reproduce

Enable microsoft-teams plugin and execute auto shipit

Expected behavior

Message in MS Teams channel looks closed to formatted version from generated CHANGELOG.md. E.g. there are URLs, multiline formatting and basic emoji icons.

screen_expected

Screenshots

screes_actual

Environment information:

Linux, sh
auto v10.29.3
git 2.20.1

Additional context

Message in MS Teams channel looks like escaped/serialized markdown version. I performed two tests:

  1. Copy message from MS Teams channel and resend it via Postman using MS Teams Web hook URL. As result got well formatted text (more-less, because URLs links was missed)
  2. I copied text from generated CHANGELOG.md file, perform JSON string escaping and send it it via Postman using MS Teams Web hook URL. As result got well formatted text (only few icons were missed, but this is MS Teams related issue).

Based on this, I conclude that MS Teams API works fine but issue is with formatting on sender side.

For example what I did manually and hat works fine:
source text from CHANGELOG.md:

:tada: This release contains work from a new contributor! :tada:

Thank you, DevName1 ([@DEV001](https://git.blahblah.com/DEV001)), for all your work!

#### 🐛 Bug Fix

- Hotfix([PROJ-1234](https://jira.blahblah.com/browse/PROJ-1234): ): use different step size for price and power filter … [#678](https://git.blahblah.com/some/repo/pull/678) ([@DEV001](https://git.blahblah.com/DEV001))

#### Authors: 1

- DevName1 ([@DEV001](https://git.blahblah.com/DEV001))

---

escaped string:

:tada: This release contains work from a new contributor! :tada:\n\nThank you, DevName1 ([@DEV001](https://git.blahblah.com/DEV001)), for all your work!\n\n#### 🐛 Bug Fix\n\n- Hotfix([PROJ-1234](https://jira.blahblah.com/browse/PROJ-1234): ): use different step size for price and power filter … [#678](https://git.blahblah.com/some/repo/pull/678) ([@DEV001](https://git.blahblah.com/DEV001))\n\n#### Authors: 1\n\n- DevName1 ([@DEV001](https://git.blahblah.com/DEV001))\n\n---

Request for MS Teams WEB Hook:

{
  "@context": "https://schema.org/extensions",
  "@type": "MessageCard",
  "themeColor": "0072C6",
  "title": "Test",
  "text": ":tada: This release contains work from a new contributor! :tada:\n\nThank you, DevName1 ([@DEV001](https://git.blahblah.com/DEV001)), for all your work!\n\n#### 🐛 Bug Fix\n\n- Hotfix([PROJ-1234](https://jira.blahblah.com/browse/PROJ-1234): ): use different step size for price and power filter … [#678](https://git.blahblah.com/some/repo/pull/678) ([@DEV001](https://git.blahblah.com/DEV001))\n\n#### Authors: 1\n\n- DevName1 ([@DEV001](https://git.blahblah.com/DEV001))\n\n---",
}

May be somehow related to sanitizeMarkdown() function inside https://github.com/intuit/auto/blob/main/plugins/microsoft-teams/src/index.ts and #1914 changes.

@redrathnure redrathnure added the bug Something isn't working label Jun 22, 2021
@hipstersmoothie
Copy link
Collaborator

I'm not a user of Microsoft teams myself. If you find something that can be improved feel free to make a PR!

@mathieubergeron
Copy link
Contributor

@vincentbriglia: We're trying to understand why the sanitizeMarkdown bit was required for you, while it seems problematic for us and others. (Related post made by @reintroducing : #1914 (comment)) Any thoughts on that?

I would be happy to make the necessary changes myself, but I would like to understand why sanitizeMarkdown was added in the first place.


Just to make sure that sanitizeMarkdown (=> jsesc) was the source of our problem, I commented the sanitizeMarkdown like so.

Before:
image

After:
image

@reintroducing
Copy link

@mathieubergeron Thank you for bring this up, it's definitely a sight for sore eyes in our Teams npm publish reporting channel :) I was going to circle back on this after my PTO in two weeks because I've had enough looking at it but looks like you've already found the issue. It would be great if we can get a new version published that fixes this. I know you're waiting on an answer but honestly, it's completely unusable as it is so I'd favor a "get this out now and answer questions later" approach if possible. @hipstersmoothie thoughts?

@vincentbriglia
Copy link
Contributor

@mathieubergeron @reintroducing i would have never pushed anything that didn't work at the time, there is no way of double checking now, but it worked for 1 commit and immediately after we got this garbled content also - we just haven't prioritized the work on our end. Feel free to create a PR, @hipstersmoothie will pull it in without doubt.

@jakobe
Copy link

jakobe commented Oct 1, 2021

@mathieubergeron @reintroducing @vincentbriglia I can confirm that removing jsesc from the mix now creates nicely formatted release messages in Teams (we create a copy of the plugin wihin our repo and remove jsesc and all is good 👍🏻 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants