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

Webhook is not working for the new line \n for RC 3.12.1 #21040

Open
Cancer-zern opened this issue Mar 9, 2021 · 24 comments
Open

Webhook is not working for the new line \n for RC 3.12.1 #21040

Cancer-zern opened this issue Mar 9, 2021 · 24 comments

Comments

@Cancer-zern
Copy link

Cancer-zern commented Mar 9, 2021

Description:

Steps to reproduce:

Expected behavior:

Actual behavior:

Server Setup Information:

  • Version of Rocket.Chat Server:
  • Operating System: 3.12.1
  • Deployment Method: snap
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: v12.18.4
  • MongoDB Version: 3.6.14

Client Setup Information

  • Desktop App or Browser Version: 3v and 2v
  • Operating System: Windows 10 20H2

Additional context

Today when my RC server has been updated i got this issue.
I have Zabbix Server and sending notification via webhooks to the channel and after the last update from v3.10.5 to 3.12.1 i got this issue.
was

PROBLEM: Response time is too high on PROXY (Warning)
Date: 2021.03.09 09:46:05
Latest value: 2s 297ms

now

PROBLEM: Response time is too high on PROXY (Warning) Date: 2021.03.09 
09:46:05 Latest value: 2s 297ms

Message what am sending to
[{TRIGGER.NAME} ({TRIGGER.SEVERITY})](https://zabbix.example.com/events.php?triggerid={TRIGGER.ID}&filter_set=1)\nDate: {EVENT.DATE} {EVENT.TIME}\nLatest value: {ITEM.VALUE1}

for example
@username 'PROBLEM' 'This is a test of something being wrong!\n123'

the message is like that
PROBLEM: This is a test of something being wrong!123

but RC app for android is showing fine/okay, the problem for web browser and desktop app.

Relevant logs:

@Cancer-zern
Copy link
Author

Cancer-zern commented Mar 9, 2021

Script
for Slack it's working, for RC current version is broken

#!/bin/bash

# Slack incoming web-hook URL and user name
url='https://ntchat.example.com/hooks/boxzaY12ppknksasasatPdsasasdasdasdasdasdasdasdasda'
username='Zabbix Monitoring'

## Values received by this script:
# To = $1 (Slack channel or user to send the message to, specified in the Zabbix web interface; "@username" or "#channel")
# Subject = $2 (usually either PROBLEM {HOST.NAME} or RECOVERY {HOST.NAME}
# Message = $3 (whatever message the Zabbix action sends, preferably something like "Zabbix server is unreachable for 5 minutes - Zabbix server (127.0.0.1)")

# Get the Slack channel or user ($1), Zabbix subject (hopefully either PROBLEM or RECOVERY), and the server in question
to="$1"
subject=$(echo $2|cut -d' ' -f1) 
server=$(echo $2|cut -d' ' -f2-) 

# Set up the alert type (future flexibility)
if [ "$subject" == 'OK' ]; then
        type="R"
elif [ "$server" == 'Information' ]; then
        type="I"
elif [ "$server" == 'Warning' ]; then
        type="W"
elif [ "$server" == 'Average' ]; then
        type="A"
elif [ "$server" == 'High' ]; then
        type="H"
elif [ "$server" == 'Disaster' ]; then
        type="D"
else
        type="N"
fi

# Change message emoji, color, and (friendly) status depending on the subject
if [ $type == 'R' ]; then  # Triggered by 'RECOVERY' above
        emoji=':smile_troll:'    # A smile,
        color="#20E020"    # and red text
elif [ $type == 'I' ]; then  # Triggered by 'PROBLEM' above
        emoji=':om_troll:'
        color="#20D6E0"
elif [ $type == 'W' ]; then  # Triggered by 'PROBLEM' above
        emoji=':om_troll:'
        color="#FAEFA6"
#        color="#E0DC20"
elif [ $type == 'A' ]; then  # Triggered by 'PROBLEM' above
        emoji=':om_troll:'
        color="#FEB48B"
#        color="#E08920"
elif [ $type == 'H' ]; then  # Triggered by 'PROBLEM' above
        emoji=':om_troll:'
        color="#E02059"
elif [ $type == 'D' ]; then  # Triggered by 'PROBLEM' above
        emoji=':om_troll:'
        color="#E02020"
else
        emoji=':ghost:'
        color="#808080"
fi

# The message that we want to send to Slack is the "subject" value ($2 / $subject - that we got earlier)
#  followed by the message that Zabbix actually sent us ($3)
message="${subject}: $3"

payload="payload={
        \"channel\": \"${to}\",
        \"username\": \"${username}\",
        \"icon_emoji\": \"${emoji}\",
        \"attachments\": [
           {
                \"fallback\": \"${message}\",
                \"text\": \"${message}\",
                \"color\": \"${color}\",
                \"mrkdwn_in\": [ \"text\" ]
           }
        ] }"

/usr/bin/curl -m 5 --data-urlencode "${payload}" $url

@Cancer-zern
Copy link
Author

but RC app for android is showing fine/okay, the problem for web browser and desktop app.

@minix-it
Copy link

minix-it commented Mar 9, 2021

Hi there, i confirm all. Since 3.12.1 community edition, \n in webhooks isnt honored in web and desktop app

@Cancer-zern Cancer-zern changed the title Webhook is not working for the new line \n Webhook is not working for the new line \n for RC 3.12.1 Mar 9, 2021
@fdellwing
Copy link

I can confirm this issue, it does work if it is wrapped in something like a code block. But not as plain text.

@Cancer-zern
Copy link
Author

I've updated to 3.13.1 and still the same issue.

@Exordian
Copy link
Contributor

Emoji/Markdown rendering is broken as well

@Cancer-zern
Copy link
Author

v3.14.4 has the same issue

@phuongnguyen2311
Copy link

image
image
I has problem same this, because we have upgrade version rocketchat to 3.16.3 then break "\n" not working
how can fixed this issue?

@fdellwing
Copy link

@phuongnguyen2311 The <br/> will be fixed by #22727

@phuongnguyen2311
Copy link

phuongnguyen2311 commented Jul 26, 2021

@phuongnguyen2311 The <br/> will be fixed by #22727

image
i will try with "<br/>" in value but not working

image

@debdutdeb
Copy link
Member

debdutdeb commented Aug 13, 2021

Fixed in 3.17.0

@fdellwing
Copy link

fdellwing commented Aug 13, 2021

@debdutdeb Sorry to say this, but this issue is not fixed with 3.17.0. New lines (\n) in attachments are still ignored/filtered out. Someone overtook this issue with the <br/> issue, that is indeed fixed in 3.17.0, but the original issue still persists.

See these screenshots:

grafik
grafik

@debdutdeb
Copy link
Member

Hmm - I'll take a look at this later today Fabian. I'll reopen the issue if it's still there. Whatever happens, I'll let you know 🙂

@fdellwing
Copy link

@debdutdeb

You can use this very simple test script to reproduce the problem:

import requests

data = {
    "text": f"Testhook:",
    "attachments": [
        {
            "text": "First Line\nSecond Line\nThird Line",
            "fields": [
                {
                    "short": True,
                    "title": "",
                    "value": f"[Link anyone?](http://example.com)",
                }
            ]
        }
    ]
}

requests.post("url to webhook", json=data)

The newlines in the attachment text will be replaced by spaces in the rendered output.

@zdumitru
Copy link
Contributor

Confirming- It's not fixed. Issue needs to be reopened. New lines are replaced with the spaces, which is wrong.

@Cancer-zern
Copy link
Author

Cancer-zern commented Aug 16, 2021

Yeah, confirm, 3.17.0 this issue is not fixed
Kindly, could you reopen this ticket, pls? @debdutdeb

@fdellwing
Copy link

@debdutdeb Any news?

@debdutdeb
Copy link
Member

Hey Dumitru, thanks for the ping at open. Sorry for not being around for a while - a lot of stuff's been going around I'm sure you guys know about already.

Anyway, reopning this, thanks.

@debdutdeb debdutdeb reopened this Sep 3, 2021
@qamaraden
Copy link

We are on version 3.18.2 and also getting this issue. All our newlines (\n) don't work

@fdellwing
Copy link

It's really sad at the moment. They push their UI rework and spend zero time in fixing bugs they introduced themself..

I really hope they start to overthink their direction or they will loose a big part of the community in the next years.

@Cancer-zern
Copy link
Author

Cancer-zern commented Jun 3, 2022

Version 4.6.3 has same issue with Windows App (v3.8.7) and via Web Browser
but Android/iOS app is showing correctly

Deployment
Version: 4.6.3
Apps Engine Version: 1.31.0
Node Version: v14.18.3
Database Migration: 258 (June 3, 2022 11:11 AM)
MongoDB: 4.2.17 / wiredTiger (oplog Enabled)
Commit Details: HEAD: (596881e)
Branch: HEAD

@ankar84
Copy link

ankar84 commented Jun 3, 2022

Looks like it is related to this issue #22732

@ankar84
Copy link

ankar84 commented Jun 3, 2022

And according to these #24924 (comment) it's not a bug, but a feature (by design). I'm not agree with that for sure!

@Cancer-zern
Copy link
Author

Cancer-zern commented Jun 29, 2022

RC Server Version: 4.8.1

./zabbix_rocketchat @UserName 'OK' 'This is a test of something being wrong\n..222'
image

./zabbix_rocketchat @UserName 'OK' 'This is a test of something being wrong\n\n..222'
image

./zabbix_rocketchat @UserName 'OK' 'This is a test of something being wrong\n\n222\n\n333'
image

I think It's not a feature it's a bug

Upd..
Mobile app showing fine with "\n" 1 time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants