argoproj / argoproj/notifications-engine

Bug: `github` service only sends last template when triggered

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

Description

## Summary

Only the last template specified in a trigger will be sent when using the `github` service. I'm not sure if this behavior extends to other services.

## Observed Behavior

Consider the following config. Note that two templates are specified in the "send" clause of the on-deployed trigger.

```yaml
trigger.on-deployed: |
- description: Application successfully deployed
send: [app-deployed, app-config-deployed]
when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'

template.app-deployed: |
message: |
Successfully deployed `{{.app.metadata.name}}`.
github:
repoURLPath: '{{((first .app.status.sync.comparedTo.sources).repoURL)}}'
revisionPath: "{{(first .app.status.sync.revisions)}}"
status:
state: success
label: "continuous-delivery/{{.app.metadata.labels.environment}}/{{.app.metadata.name}}"
targetURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"

template.app-config-deployed: |
message: |
Successfully deployed `{{.app.metadata.name}}` with this config.
github:
repoURLPath: "git:github.com:org/config.git"
revisionPath: "{{(last (last .app.status.history).revisions)}}"
status:
state: success
label: "continuous-delivery/{{.app.metadata.labels.environment}}/{{.app.metadata.name}}"
targetURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
```

Only the `app-config-deployed` notification will be sent. The service quietly fails to send `app-deployed`. Not even a debug log is emitted.

## Expected Behavior

1. I expect an error log when a notification fails to send.
2. I expect every templates/notifications specified in the `send` configuration of the trigger to be sent.
3. I expect any deviation from this behavior to be documented.

## Version

```
notifications-engine@v0.4.1-0.20230620204159-3446d4ae8520
```

## Logs

```
info: Trigger on-deployed result: [{[0].y7b5sbwa2Q329JYH755peeq-fBs [app-deployed app-config-deployed] true}]
info: Sending notification about condition 'on-deployed.[0].y7b5sbwa2Q329JYH755peeq-fBs' to '{github }'
debug: Sending request: POST /app/installations/redacted/access_tokens
debug: msg="Received response: HTTP/2.0 201 Created
debug: msg="Sending request: POST /repos/org/config/statuses/17b9362483179c29dfb79a5aa4bc7b41e01a229f
debug: msg="Received response: HTTP/2.0 201 Created\r
debug: Notification was sent
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the provided trigger and two-template configuration, then trace the github service notification path to see how multiple templates are handled and where send errors are discarded. Done means every template in the trigger is sent, failures produce an error log, and any intentional service-specific behavior is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, go
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.