get_chain() function can raise TypeError

Bug #1972659 reported by Martin Kalcok
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
vault-charm
New
Undecided
Unassigned

Bug Description

Unfortunately I don't have steps to reproduce this consistently. It happened to me when vault units were changing leadership.

Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-vault-1/.venv/lib/python3.8/site-packages/charms/reactive/__init__.py", line 74, in main
    bus.dispatch(restricted=restricted_mode)
  File "/var/lib/juju/agents/unit-vault-1/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 390, in dispatch
    _invoke(other_handlers)
  File "/var/lib/juju/agents/unit-vault-1/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 359, in _invoke
    handler.invoke()
  File "/var/lib/juju/agents/unit-vault-1/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 181, in invoke
    self._action(*args)
  File "/var/lib/juju/agents/unit-vault-1/charm/reactive/vault_handlers.py", line 967, in publish_ca_info
    chain = vault_pki.get_chain()
  File "/var/lib/juju/agents/unit-vault-1/charm/lib/charm/vault_pki.py", line 87, in get_chain
    return client.read('{}/cert/ca_chain'.format(name))['data']['certificate']
TypeError: 'NoneType' object is not subscriptable

I think that either the docstring of the function should be changed to indicate that this exception can be raised by the function (right now the docstring is copy-pasted from is_ca_ready()), or ideally the function should catch the exception and return appropriate value (None, "" ?)

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.