Abd
(Mec)
January 15, 2024, 3:09pm
1
Notification is not sent when custom data in the notification template contains a string that contains double or single quotes. I am using a webhook, that posts some data. I am also using job.artifacts
to pass some data to the notification template. I have listed the two problamatic cases below.
Has anyone encountered this or is fmailiar with what is the cause for this behaviour.
Any help is highly appreciated
AWX version
23.5.1
Ansible version
2.11.12
Operating system
CentOS
Steps to reproduce
A playbook that contains the following:
- hosts: all
gather_facts: true
tasks:
- name: "[playbook_simple_test] Test Task."
ansible.builtin.set_stats:
aggregate: false
per_host: false
data:
"{{ data_obj }}"
register: some_test
The notification template contains the following:
{{ job_metadata }}
{
"job.id": "{{ job.id }}",
"job.status": "{{ job.status }}",
"job.artifacts": "{{ job.artifacts }}"
}
{
"job.id": "{{ job.id }}",
"job.status": "{{ job.status }}",
"job.artifacts": "{{ job.artifacts }}"
}
There are the following three cases in a job template:
w/o double quotes ("):
Extra-vars:
{
"data_obj": {
"some_str": "This contains no double quotes."
}
}
contains double quotes ("):
Extra-vars:
{
"data_obj": {
"some_str": "This contains double quotes \" in the middle of text."
}
}
contains a stringified json
{
"data_obj": {
"some_str": "{\"key1\": \"value1\", \"key2\": \"value2\"}"
}
}
Expected results
metadata
{âjob.idâ: âxxxxxâ, âjob.statusâ: âsuccessfulâ, âjob.artifactsâ: {âsome_strâ: âstring contentâ}}
Actual results
w/o double quotes in string:
metadata
{âjob.idâ: âxxxxxâ, âjob.statusâ: âsuccessfulâ, âjob.artifactsâ: {âsome_strâ: âThis contains double quotes " in the middle of text.â}}
contains double quotes ("):
metadata
No Notification
contains stringified json:
metadata
No Notification
djyasin
(Lila Yasin)
January 17, 2024, 7:59pm
2
Hello @Abd we did see your GitHub Issue and this does seem to be a bug. We are continuing to triage this on your issue. Thank you for bringing this to our attention!
opened 09:35AM - 11 Jan 24 UTC
type:bug
component:api
community
### Please confirm the following
- [X] I agree to follow this project's [code⌠of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.
- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.
- [X] I am **NOT** reporting a (potential) security vulnerability. (These should be emailed to `security@ansible.com` instead.)
### Bug Summary
Notification is not sent when custom data in the notification template contains a string that contains double or single quotes. I have listed two use cases below.
### AWX version
23.5.1
### Select the relevant components
- [ ] UI
- [ ] UI (tech preview)
- [X] API
- [ ] Docs
- [ ] Collection
- [ ] CLI
- [ ] Other
### Installation method
kubernetes
### Modifications
no
### Ansible version
2.11.12
### Operating system
CentOS
### Web browser
_No response_
### Steps to reproduce
A playbook that contains the following:
```YAML
- hosts: all
gather_facts: true
tasks:
- name: "[playbook_simple_test] Test Task."
ansible.builtin.set_stats:
aggregate: false
per_host: false
data:
"{{ data_obj }}"
register: some_test
```
The notification template contains the following:
- Created:
```YAML
{{ job_metadata }}
```
- Success message body:
```YAML
{
"job.id": "{{ job.id }}",
"job.status": "{{ job.status }}",
"job.artifacts": "{{ job.artifacts }}"
}
```
- Error message body:
```YAML
{
"job.id": "{{ job.id }}",
"job.status": "{{ job.status }}",
"job.artifacts": "{{ job.artifacts }}"
}
```
There are the following two cases in a job template:
1. w/o double quotes ("):
Extra-vars:
```json
{
"data_obj": {
"some_str": "This contains no double quotes."
}
}
```
2. contains double quotes ("):
Extra-vars:
```json
{
"data_obj": {
"some_str": "This contains double quotes \" in the middle of text."
}
}
```
3. contains stringified json
```json
{
"data_obj": {
"some_str": "{\"key1\": \"value1\", \"key2\": \"value2\"}"
}
}
```
### Expected results
metadata
{"job.id": "xxxxx", "job.status": "successful", "job.artifacts": {"some_str": "string content"}}
### Actual results
1. w/o double quotes in string:
metadata
{"job.id": "xxxxx", "job.status": "successful", "job.artifacts": {"some_str": "This contains double quotes \" in the middle of text."}}
2. contains double quotes ("):
metadata
**No Notification**
3. contains stringified json:
metadata
**No Notification**
### Additional information
_No response_