argoproj / argoproj/notifications-engine

slack message template: invalid character '}' looking for beginning of object key string

Open
#81 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
334
Forks
217
PR merge metrics
No merged PRs in 30d

Description

i create a template for a message to slack:
```yaml
templates:
template.test: |
slack:
attachments: |
[{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<{{.app.spec.source.repoURL}}/commit/{{.app.status.sync.revision}}|{{(call .repo.GetCommitMetadata .app.status.sync.revision).Message}}> by {{(call .repo.GetCommitMetadata .app.status.sync.revision).Author}} in {{ .context.environment }}",
}
}
]
}]
```
which is an attachment like:
```
{
"attachments": [
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": " by author in dev:cookie:"
}
}
]
}
]
}
```
and according to the slack [block kit builder](https://app.slack.com/block-kit-builder/T2NR19KSR#%7B%22attachments%22:%5B%7B%22blocks%22:%5B%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22mrkdwn%22,%22text%22:%22%3Chttps://github.com/repo/commit/sha%7Cgithub%3E%20by%20author%20in%20dev:cookie:%22%7D%7D%5D%7D%5D%7D) this is ok.
but in the `argocd-notifications-controller` I get this error:
```
level=error msg="Failed to notify recipient {slack argocd-notifications} defined in resource argo-cd/keycloak: failed to unmarshal attachments '[{\n \"blocks\": [\n {\n \"type\": \"section\",\n \"text\": {\n \"type\": \"mrkdwn\",\n \"text\": \" by author in dev:cookie:\",\n } \n }\n ]\n}]\n' : invalid character '\\n' in string literal" resource=argo-cd/keycloak
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the argocd-notifications-controller path that unmarshals Slack attachments and reproduce the failure with the YAML template shown in the issue. Compare the controller's accepted attachment payload with the valid Block Kit example, then verify that the template produces a notification without an unmarshalling error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.