and in this case it looks like either event does not have app attribute or it is None.
Which produces event.relation.data[None] and that causes an error.
simple fix will be to check for event.app, but I am not sure I do everything correct
To Reproduce
relate two charms like juju relate prometheus-k8s:send-remote-write prom-read:receive-remote-write
ERROR unit.prometheus-k8s/0.juju-log send-remote-write:22: Uncaught exception while in charm code:
Traceback (most recent call last):
File "./src/charm.py", line 806, in <module>
main(PrometheusCharm)
File "/var/lib/juju/agents/unit-prometheus-k8s-0/charm/venv/ops/main.py", line 431, in main
_emit_charm_event(charm, dispatcher.event_name)
File "/var/lib/juju/agents/unit-prometheus-k8s-0/charm/venv/ops/main.py", line 142, in _emit_charm_event
event_to_emit.emit(*args, **kwargs)
File "/var/lib/juju/agents/unit-prometheus-k8s-0/charm/venv/ops/framework.py", line 316, in emit
framework._emit(event)
File "/var/lib/juju/agents/unit-prometheus-k8s-0/charm/venv/ops/framework.py", line 784, in _emit
self._reemit(event_path)
File "/var/lib/juju/agents/unit-prometheus-k8s-0/charm/venv/ops/framework.py", line 857, in _reemit
custom_handler(event)
File "/var/lib/juju/agents/unit-prometheus-k8s-0/charm/lib/charms/prometheus_k8s/v0/prometheus_remote_write.py", line 644, in _handle_endpoints_changed
ev = json.loads(event.relation.data[event.app].get("event", "{}"))
File "/var/lib/juju/agents/unit-prometheus-k8s-0/charm/venv/ops/model.py", line 899, in __getitem__
return self._data[key]
KeyError: None
Bug Description
either I am doing something wrong, but every time I remove relation, I get an error state with below mentioned trace.
path of the code that raises an error is: https://github.com/canonical/prometheus-k8s-operator/blob/dc3dc60f198f8dfc840f4da6f98f295ff8b9b97d/lib/charms/prometheus_k8s/v0/prometheus_remote_write.py#L643
and in this case it looks like either
event
does not haveapp
attribute or it isNone
. Which producesevent.relation.data[None]
and that causes an error.simple fix will be to check for
event.app
, but I am not sure I do everything correctTo Reproduce
relate two charms like
juju relate prometheus-k8s:send-remote-write prom-read:receive-remote-write
break relation:
juju remove-relation prometheus-k8s prom-read
Environment
microk8s
Relevant log output
Additional context
No response