Unicode double quotes on config.yaml file causes UnicodeDecodeError

Bug #1945507 reported by Facundo Ciccioli
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Calico Charm
New
Undecided
Unassigned

Bug Description

I was in the process of upgrading from revision 812 to 826, when all the units went into error state due to the hook having failed.

Upon a closer look at one of the unit's logs:

2021-09-29 15:14:33 ERROR juju-log Hook error:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-calico-1/.venv/lib/python3.6/site-packages/charms/reactive/__init__.py", line 73, in main
    hookenv._run_atstart()
  File "/var/lib/juju/agents/unit-calico-1/.venv/lib/python3.6/site-packages/charmhelpers/core/hookenv.py", line 1352, in _run_atstart
    callback(*args, **kwargs)
  File "lib/charms/layer/basic.py", line 480, in init_config_states
    config_defs = yaml.safe_load(fp).get('options', {})
  File "/var/lib/juju/agents/unit-calico-1/.venv/lib/python3.6/site-packages/yaml/__init__.py", line 162, in safe_load
    return load(stream, SafeLoader)
  File "/var/lib/juju/agents/unit-calico-1/.venv/lib/python3.6/site-packages/yaml/__init__.py", line 112, in load
    loader = Loader(stream)
  File "/var/lib/juju/agents/unit-calico-1/.venv/lib/python3.6/site-packages/yaml/loader.py", line 34, in __init__
    Reader.__init__(self, stream)
  File "/var/lib/juju/agents/unit-calico-1/.venv/lib/python3.6/site-packages/yaml/reader.py", line 85, in __init__
    self.determine_encoding()
  File "/var/lib/juju/agents/unit-calico-1/.venv/lib/python3.6/site-packages/yaml/reader.py", line 124, in determine_encoding
    self.update_raw()
  File "/var/lib/juju/agents/unit-calico-1/.venv/lib/python3.6/site-packages/yaml/reader.py", line 178, in update_raw
    data = self.stream.read(size)
  File "/var/lib/juju/agents/unit-calico-1/.venv/lib/python3.6/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 292: ordinal not in range(128)

And indeed, the config.yaml file has 4 double quotes typed with the unicode char 0x201d.

The obvious workaround of replacing those quotes per "regular" ones fixed the issue.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.