matrix-docker-ansible-deploy icon indicating copy to clipboard operation
matrix-docker-ansible-deploy copied to clipboard

`to_json` breaks emoji in Hookshot displayname

Open HarHarLinks opened this issue 2 years ago • 2 comments

https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/0c6959de8b0e3a3013a3ea7c376ca969ee4a1165/roles/custom/matrix-bridge-hookshot/templates/config.yml.j2#L104

Setting an emoji such as matrix_hookshot_bot_displayname: 🌉 Hookshot becomes displayname: "\ud83c\udf09 Hookshot" in the config.yml which then fails

fatal: [matrix.example.org]: FAILED! => 
  msg: |-
    An unhandled exception occurred while templating '{{ matrix_hookshot_configuration_yaml | from_yaml | combine(matrix_hookshot_configuration_extension, recursive=True) }}'. Error was a <class 'yaml.scanner.ScannerError'>, original message: while parsing a quoted scalar
      in "<unicode string>", line 71, column 16
    found invalid Unicode character escape code
      in "<unicode string>", line 71, column 19

It works without to_json.

HarHarLinks avatar Dec 17 '22 16:12 HarHarLinks

Maybe we need to use to_json(ensure_ascii=False)? https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_filters.html#filter-to-json-and-unicode-support

spantaleev avatar Dec 17 '22 16:12 spantaleev

seems to work. this might apply to all similar settings as well.

HarHarLinks avatar Dec 18 '22 12:12 HarHarLinks