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

JSON special characters show up escaped #7

Closed
wagdav opened this issue Nov 22, 2019 · 3 comments · Fixed by #8
Closed

JSON special characters show up escaped #7

wagdav opened this issue Nov 22, 2019 · 3 comments · Fixed by #8
Assignees
Labels
bug Something isn't working

Comments

@wagdav
Copy link
Contributor

wagdav commented Nov 22, 2019

Hi @mr-karan,
Thanks for making calert, we just deployed it at Pix4D and we're really happy with it!

We noticed the following issue. Take an alert where, for example, the summary field contains " characters:

# test-payload.json
{
    "alerts": [
        {
            "status": "firing",
            "annotations": {
                "summary": "Server \"foo\" is down"
            }
        }
    ]
}

Now send this to calert

curl -XPOST -d @test-payload.json http://localhost:6000/create?room_name=test -i

The following message shows up in the targeted Hangouts Chat channel (using the default message template):

summary: Server "foo" is down

In this case, I'd expect the double quotes to be kept and not escaped.

@mr-karan
Copy link
Owner

@wagdav Thanks for reporting. I'll investigate this.

@mr-karan mr-karan added the bug Something isn't working label Nov 22, 2019
@mr-karan mr-karan self-assigned this Nov 22, 2019
@wagdav
Copy link
Contributor Author

wagdav commented Dec 2, 2019

@mr-karan Did you have a chance to take a look at this?

If you could point me to a place in the code where the problem could happen I could try to submit a PR with a fix.

Thanks!

@mr-karan
Copy link
Owner

mr-karan commented Dec 2, 2019

@wagdav Been caught up with some things, my bad. Feel free to take this up

This is the part where I try to decode the alertmanager payload:
https://github.com/mr-karan/calert/blob/master/api.go#L95

Over here, is when I transform this payload to what Google Chat expects:
https://github.com/mr-karan/calert/blob/master/api.go#L100

I guess we should check for unescaped characters while populating the template, which is here:

err = tmpl.Execute(&to, a)

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

Successfully merging a pull request may close this issue.

2 participants