reanahub / reana-server

REANA API server
http://reana-server.readthedocs.io/
MIT License
5 stars 37 forks source link

config: allow emojis in reana-ui announcement #677

Open mdonadoni opened 7 months ago

mdonadoni commented 7 months ago

Trying to put emojis in the reana-ui announcement results in the following error:

  File "/code/./reana_server/rest/config.py", line 75, in get_config
    jsonify(REANAConfig.load("ui")),
  File "/usr/local/lib/python3.8/dist-packages/reana_commons/config.py", line 40, in load
    return cls._read_file(cls.config_mapping[kind])
  File "/usr/local/lib/python3.8/dist-packages/reana_commons/config.py", line 30, in _read_file
    data = yaml.load(yaml_file, Loader=yaml.FullLoader)
  File "/usr/local/lib/python3.8/dist-packages/yaml/__init__.py", line 79, in load
    loader = Loader(stream)
  File "/usr/local/lib/python3.8/dist-packages/yaml/loader.py", line 24, in __init__
    Reader.__init__(self, stream)
  File "/usr/local/lib/python3.8/dist-packages/yaml/reader.py", line 85, in __init__
    self.determine_encoding()
  File "/usr/local/lib/python3.8/dist-packages/yaml/reader.py", line 124, in determine_encoding
    self.update_raw()
  File "/usr/local/lib/python3.8/dist-packages/yaml/reader.py", line 178, in update_raw
    data = self.stream.read(size)
  File "/usr/lib/python3.8/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 38: ordinal not in range(128)

Probably a locale-related issue, as inside the reana-server's pod the default locale is POSIX:

$ locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

Note that manually modifying the ConfigMap removing the Unicode character and adding its escaped counterpart works well. However, I haven't found a way to make Helm maintain the escaped sequence when generating the ConfigMap.

From:

apiVersion: v1
data:
  ui-config.yaml: |
    announcement: "Trying out some emojis ⭐"
...

To:

apiVersion: v1
data:
  ui-config.yaml: |
    announcement: "Trying out some emojis \u2B50"
...